rand(Date.civil(1990, 1, 1)..Date.civil(2050, 12, 31))
мой любимый метод
def random_date_in_year(year)
return rand(Date.civil(year.min, 1, 1)..Date.civil(year.max, 12, 31)) if year.kind_of?(Range)
rand(Date.civil(year, 1, 1)..Date.civil(year, 12, 31))
end
затем используйте как
random_date = random_date_in_year(2000..2020)