Re: MS SQL server and SQL DATETIME manipulation in perl
- From: Jonathan Leffler <jleffler@xxxxxxxxxxxxx>
- Date: Sat, 30 Apr 2005 08:10:20 GMT
Bob wrote:
Hi all,
I am going to be doing a lot of work with Microsoft SQL Server 2000 using perl and the Win32::ODBC module. Most of this will revolve around date and time conversions, and as such I was wondering if anyone has come up with a module(s) for converting between SQL Server DATETIME strings and perls epoch serial numbers.
I have already checked the Date::Calc and Date::Manip modules from CPAN, and they do not include such code.
MS SQL DATETIME types (ANSI SQL-92 standard?) should be delimited and formated as follows, for server INSERTS statements:
'YYYYMMDD' 'YYYY-MM-DDTHH:MM:SS' 'YYYY-MM-DDTHH:MM:SS.xxx'
So for example I would like to go from: 549929310551181, or Fri Apr 29 09:49:05 2005 to: 20050429, or 2005-04-29T09:49:05, or 2005-04-29T09:49:05.333
and vice-versa, and the time component as optional too, etc.
I am sure one of you guys out there has done this before, right?
Look at the DateTime::* modules on CPAN.
http://datetime.perl.org/
-- Jonathan Leffler #include <disclaimer.h> Email: jleffler@xxxxxxxxxxxxx, jleffler@xxxxxxxxxx Guardian of DBD::Informix v2005.01 -- http://dbi.perl.org/ .
- References:
- Prev by Date: Looking for SNMP-5.1.1/NetSNMP-5.1.1
- Previous by thread: Re: MS SQL server and SQL DATETIME manipulation in perl
- Next by thread: Installation LDAP
- Index(es):
Relevant Pages
|
|