Comparind dates

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

On 6/15/07, Mecharek M. [email protected]
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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs