• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1053
  • Last Modified:

Fastest way in PERL to compare dates in the following form: YYYY-MM-DD hh:mm:ss

How can you compare dates in PERL with the following date format:YYYY-MM-DD hh:mm:ss
For example: 06-10-26 13:00:06 is greater than 06-10-26 11:27:28
0
angelsky
Asked:
angelsky
2 Solutions
 
ozoCommented:
if( '06-10-26 13:00:06' gt '06-10-26 11:27:28' ){ print 'greater' }
0
 
TalmashCommented:
Y2K bug...
you noted YYYY and used YY...

another issue, moving to
0
 
TintinCommented:
Your description and sample data don't match.  Which is correct?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
angelskyAuthor Commented:
Sorry my mistake...
 2006-10-26 13:00:06 is greater than 2006-10-26 11:27:28
Because "2006-10-26 13:00:06 " is later than "2006-10-26 11:27:28"
0
 
angelskyAuthor Commented:
$dateA = "2006-10-26 13:00:06";
$dateB = "2006-10-26 11:27:28";

How can I say that dateA is after dateB?
0
 
TintinCommented:
As ozo has already shown

$dateA = "2006-10-26 13:00:06";
$dateB = "2006-10-26 13:27:28";

if ($dateA gt $dateB) {
  print "$dateA is later than $dateB\n";
}
else {
  print "$dateB is later than $dateA\n";
}
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now