Re: MS SQL server and SQL DATETIME manipulation in perl



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/ .



Relevant Pages

  • MS SQL server and SQL DATETIME manipulation in perl
    ... I am going to be doing a lot of work with Microsoft SQL Server 2000 ... using perl and the Win32::ODBC module. ... date and time conversions, and as such I was wondering if anyone has ... come up with a modulefor converting between SQL Server DATETIME ...
    (comp.lang.perl.modules)
  • Re: How to access MS Access from Perl?
    ... if you were to later migrate to MS SQL Server or Oracle ... minimize your load on the database server's compiled procedure cache. ... On the other hand, if startup time for your perl script is an issue, and ... slightly preferable to the bulkier DBI + DBD::ODBC. ...
    (comp.lang.perl)
  • RE: Accessing MS SQL Server data using PERL and DBI
    ... Accessing MS SQL Server data using PERL and DBI ... If it's just simple lookups, ... I have read only access to the SQL SERVER database. ...
    (perl.dbi.users)
  • Re: Access and SQL Server Speed Comparison
    ... It may very well be faster to export the data, manipulate it in perl which ... that language, and thus I could cut down the total time, that is ... factors to determine whether to do this in Access or SQL Server. ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: perl DBI on windows 64
    ... frustration I almost abandoned the Perl approach. ... For capturing sql server print statements see the t/20SqlServe test which contains an example. ... Ramakrishna Raju ... My Perl on the 64-bit windows is 32 bit. ...
    (perl.dbi.users)