ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-win32-database
perl-win32-database
RE: Comparing Dates
by Steve Howard other posts by this author
Nov 26 2007 8:04PM messages near this date
Comparing Dates | RE: Comparing Dates
Remove the dashes and compare them numerically, or with a string compare. Be sure it is yyyy
-mm-dd and not yyyy-m-d, though. It works out like this:

2007-12-23 comes well after 2005-01-01, so comparing 20071223 >  20050101.

A string compare works even without removing the dashes. Removing the dashes lets you compar
e either for == or for eq.

Steve Howard

From: perl-win32-database-bounces@[...].com [mailto:perl-win32-database-bounces@[...].com] O
n Behalf Of Jonathan Dudson
Sent: Monday, November 26, 2007 2:39 PM
To: perl-win32-database@[...].com
Subject: Comparing Dates

Hi Peeps hopefully someone can point me in the right direction.

I have a couple of dates I have stored in a mysql DB stored in the following format yyyy-mm-
dd, how in a Perl script how can I test if date 1 is less than or equal to date 2.

Any help would be greatly appreciated.


Jay
Thread:
Jonathan Dudson
Steve Howard
Justin Allegakoen

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved