I have some dates I need to compare. One comes from a database query and the other comes from a data calculation at script execution.
# calculate data on run time to even previous hour my $dt = POSIX::strftime("%Y-%m-%d", localtime( shift( @_ ) || time ) +); my $hr = POSIX::strftime("%H", localtime( shift( @_ ) || time ) ); my $bhr = $hr - 1; my $bdt = "$dt $bhr:00:00"; # this one comes from the DB but it looks like this my $db_date = "2015-04-08 12:42:13"; # this is what I want to do if ($db_date <= $bdt) { # process }
But, obviously, that will not work:
Argument "2015-04-09 12:00:00" isn't numeric in numeric le (<=) at ./c +hk_notify_threshold.pl line 57. Argument "2015-04-09..." isn't numeric in numeric le (<=) at ./chk_not +ify_threshold.pl line 57.
How would I go about comparing these dates? Are there functions that will turn this string into a number?
In reply to Compare Dates by bfdi533
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |