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 Justin Allegakoen other posts by this author
Nov 26 2007 3:29PM messages near this date
RE: Comparing Dates | Anyone still monitor?
--------8<------------
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.
--------8<------------

Since the dates are already in yyyy/mm/dd format using Date::Calc would be the easiest:-

D:\Perl\Programs> perl
use strict;
use warnings;
use Date::Calc qw( Delta_Days );

print Delta_Days(2006, 12, 25, 2007, 12, 25);
^D
365
D:\Perl\Programs> 

But why not put the onus on the sql server by using a datediff? Typically sql servers are ab
le to handle those type of transactions with less resources.

Just in

_______________________________________________
Perl-Win32-Database mailing list
Perl-Win32-Database@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Jonathan Dudson
Steve Howard
Justin Allegakoen

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved