Solved

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

Posted on 2007-11-14
6
1,043 Views
Last Modified: 2012-08-14
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
Comment
Question by:angelsky
6 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 30 total points
ID: 20279128
if( '06-10-26 13:00:06' gt '06-10-26 11:27:28' ){ print 'greater' }
0
 
LVL 6

Expert Comment

by:Talmash
ID: 20279347
Y2K bug...
you noted YYYY and used YY...

another issue, moving to
0
 
LVL 48

Expert Comment

by:Tintin
ID: 20282910
Your description and sample data don't match.  Which is correct?
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

Author Comment

by:angelsky
ID: 20287159
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
 

Author Comment

by:angelsky
ID: 20287259
$dateA = "2006-10-26 13:00:06";
$dateB = "2006-10-26 11:27:28";

How can I say that dateA is after dateB?
0
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 20 total points
ID: 20287281
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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Removing file extension within a file. 4 92
Port 80 requests 16 95
PHP equivalent of opening a com object 5 83
PERL variable conundrum 9 90
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question