I could do [the sensible thing], but I'd rather a perlish way to do it.
If you're dead-set against doing the comparison in SQL, you could use DateTime::Format::MySQL to convert the dates to DateTime objects, ->add(days=>1), and compare to DateTime->now() using DateTime->compare(). This will not perform as well (in terms of execution time) as doing it in SQL, however. It would be one thing if you were occasionally checking a date this way, or if you were doing more complex things with the dates and needed the extra functionality DateTime provides, but if all you're doing is looping through all the rows of a table and getting a list of the ones where a certain field is less than a day ago, throwing a WHERE clause into the query seems like a much better solution to me. Really, it does. Even if you're mostly not directly interacting with the DB at the SQL level (e.g., if you're using an abstraction layer like Class::DBI), you still could use a single SQL query just to build a list of record IDs that you want and then map those over to your abstraction-layer objects.
In reply to Re: Detecting 1 day ago
by jonadab
in thread Detecting 1 day ago
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |