If you're retrieving your SQL DATETIME as a string, use something like Time::Piece's strptime or DateTime::Format::Strptime to convert it to a better representation, then use the provided methods to compare.
use DateTime (); use DateTime::Format::Strptime (); print DateTime::Format::Strptime ->new(pattern => '%Y-%m-%d %H:%M:%S.%3N') ->parse_datetime('2012-01-31 00:00:00.000') ->truncate(to=>'day') ->compare( DateTime->today ); # compare returns 0 if they're equal
That might seem like a little overkill for what could be done with a simple string comparison of two dates in the same format, but can be very useful once time zones or other DateTime features get involved.
In reply to Re: sql datetime value with today
by Anonymous Monk
in thread sql datetime value with today
by fionbarr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |