# Comparind dates

**URL:** <https://www.ruby-forum.com/t/comparind-dates/106916>\
**Category:** Rails\
**Created:** [June 15, 2007, 11:14am UTC](https://www.ruby-forum.com/t/comparind-dates/106916 "2007-06-15T11:14:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![massi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b9e5f3/32.png) [@massi](https://www.ruby-forum.com/u/massi)\
**Post date:** [June 15, 2007, 11:14am UTC](https://www.ruby-forum.com/t/comparind-dates/106916/1 "2007-06-15T11:14:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![massi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b9e5f3/32.png) [@massi](https://www.ruby-forum.com/u/massi)\
**Post date:** [June 15, 2007, 11:38am UTC](https://www.ruby-forum.com/t/comparind-dates/106916/2 "2007-06-15T11:38:13Z")

</div>

On 6/15/07, Mecharek M. [removed\_email\_address@domain.invalid](mailto: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
