Comparind dates


#1

hello,

i have to dates :

@date_1 = date.new()

@date_2 = date.new()

i want to compare theses two dates

i have tried

@date_1 > @ date_2 but every time it returns me FALSE

is there a solution .???

thanks


#2

On 6/15/07, Mecharek M. removed_email_address@domain.invalid
wrote:

i want to compare theses two dates

i have tried

@date_1 > @ date_2 but every time it returns me FALSE

is there a solution .???

thanks

This is returning false because the same date is returned by a call to
Date.new which defaults to 0. ( Mon, 01 Jan -4712 )

Instead you could use
Date.today > ( Date.today - 1 ) # => true
Date.civil( 2007, 12, 31 ) > Date.civil( 2007, 12, 30 ) # => true

Hope that helps.

Cheers