Up Prev Next
From: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: Date formats and Sybase
Date: Jul 10 2001 2:10PM
Arne Claassen writes:
> > You can even
> > play around with things to extract an "epoch" based time
> > (i.e. something like a what time() returns) and pass that to
> > localtime/strftime/etc.
> Do you mean there is a way for Sybase to return an epoch based time, or to
> use perl to parse the string and then use timelocal to get epoch time. The
> former would be great since epoch time is what we want to get things into
> most of the time.
Well - you need to use datediff() to create a "seconds since jan 1
1970" value in the query, so it's not *really* a lot better than what
you already have.
Alternatively, in perl you can set UseDateTime which will create a
DateTime object for each datetime field, and you can then use
$date->crack and various other functions to split it out and format it
as you wish. The downside is that this is somewhat slow (because of
the object creation for each date column retrieved).
You can probably also do some funkier stuff, by doing a
convert(binary(8), datecolumn) and then using unpack() to extract the
two 32bit int values that make up the datetime value... but this
starts to get a little hairy :-)
Michael Peppler - Data Migrations Inc. - http://www.mbay.net/~mpeppler
email@example.com - firstname.lastname@example.org
International Sybase User Group - http://www.isug.com