views:

66

answers:

3

how to compare particular date with today to know whether that paricular date is greater than today

Thanks Harish.

+1  A: 

If you're using date objects, you just compare as expected.

date1 > date2
Matchu
+2  A: 
@date = "2010-07-20".to_date # 20th July
@today=Date.today # 21st July

if @date >= @today
  puts "@date is greater than or equal to today's date"
else
  puts "@date is less than today's date"  
end

O/P

@date is less than today's date
Salil
thanks dude ,i will try it
harish
A: 

date object has future? and past? methods. It's the best way I can think of.

samuil