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,039 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now