hypee
hypee

Reputation: 718

Date comparison failed

I try to compare to date. I It works successfully on development mode, but the production has behaviour different.

object_date.to_date <= Date.today

The prompt of two date : 2014-04-02T00:00:00+0000 vs 2014-01-15T00:00:00+0000

And the code raises failed with ArgumentError: comparison of Date with Time failed

This code was executed in delayedjob.

I don't understand why the comparison failed.

Upvotes: 0

Views: 92

Answers (1)

thinkgruen
thinkgruen

Reputation: 1

to_date will return self, so I think for some reason object_time is a Time-object rather than a Date-object. If changing the type of object_time is not acceptable, you will have to parse the time first using the parse method in Date.

Try if Date.parse(object_date.to_date.to_s) <= Date.today will do the job.

Upvotes: 1

Related Questions