Re: DBD::Sybase ISO date format returns January as "00"?!!

Michael Peppler <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase
Message-ID <[email protected]>
On Thu, 2005-01-27 at 13:54, [email protected] wrote:
> Sorry if this is trivial but I've done as much Googling as I can stand
> without having turned up anything relevant.
> 
> I'm using "ISO" date format on a Sybase $dbh, but the month numbers are
> coming back zero based (January is "00"). As I read ISO 8601 it *should* be
> "01". Any clues? For example:

I'm deeply embarrassed by this one. It's an off-by-one error in the
formating: DBD::Sybase uses the cs_dt_crack() call to split the datetime
value into its components, and the docs clearly state that the month is
in the 0-11 range (just as it is with gmtime/localtime() in C or perl).

You can fix this easily: edit dbdimp.c, and around like 4450 you'll see
the cs_dt_crack() call, followed by the sprintf() calls that format the
date. Add 1 to then rec.datemonth argument to sprintf() and you'll be
fine.

It'll obviously be fixed in the next release...

Michael
-- 
Michael Peppler  -  [email protected]  -  http://www.peppler.org/
Sybase DBA/Developer
Sybase on Linux FAQ: http://www.peppler.org/FAQ/linux.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.