bfdi533 has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Compare Dates
by jeffa (Bishop) on Apr 09, 2015 at 20:15 UTC | |
|
Re: Compare Dates
by runrig (Abbot) on Apr 09, 2015 at 18:31 UTC | |
by trippledubs (Deacon) on Apr 09, 2015 at 23:00 UTC | |
by Random_Walk (Prior) on Apr 10, 2015 at 15:45 UTC | |
by choroba (Cardinal) on Apr 10, 2015 at 07:46 UTC | |
by trippledubs (Deacon) on Apr 10, 2015 at 13:02 UTC | |
|
Re: Compare Dates
by pme (Monsignor) on Apr 09, 2015 at 18:29 UTC |