def date_between(range)
      min_date = range.min.is_a?(Date) ? range.min : Date.parse(range.min)
      max_date = range.max.is_a?(Date) ? range.max : Date.parse(range.max)

      diff = (max_date - min_date).to_i
      min_date + rand(diff)
    end
def date_between(range)
      min_date = range.min.is_a?(Date) ? range.min : Date.parse(range.min)
      max_date = range.max.is_a?(Date) ? range.max : Date.parse(range.max)

      diff = (max_date - min_date).to_i
      min_date + rand(diff)
    end
Returns a date within the specified Range. The Range can be Date or String objects.

Example:
 min = Date.parse('1966-11-15')
 max = Date.parse('1990-01-01')
 Random.date(min..max) # => a Date between 11/15/1996 and 1/1/1990
 Random.date('1966-11-15'..'1990-01-01') # => a Date between 11/15/1996 and 1/1/1990