|
|
sybperl-l Archive
Up Prev Next
From: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: Datetime data issue
Date: Sep 21 1999 7:05PM
Andhavarapu, Srinivas writes:
> Hi,
> When I am retrieving a datetime data from Sybase 11, I am getting different
> values with different Sybperl versions.
> Here is an example of what is happening.
>
> We have a development environment which has Sybase 11 with Perl 5.004_04 and
> Sybperl 2.09
> When I retrieve a datetime data, it returns in the format "Dec 21 1999
> 2:30:28:940PM"
>
> The same thing when I try on our production server which has Sybase 11 with
> Perl 5.005_03 and Sybperl 2.1
> it returns in the format "Dec 21 1999 2:30PM" It is truncating the seconds
> and the milliseconds part of the data.
>
> I need the seconds and milliseconds information. Is there anyway to get
> that info. I did try with a convert function, but it did not seem to work.
> Any help is appreciated.
This is a locale issue, and is dependent on the version of OpenClient
that you use, not on sybperl itself.
If you use Sybase::CTlib you can use cs_dt_info() to set the
conversion format - from the sybperl man page:
$ret = cs_dt_info($action, $type, $item, $buf)
cs_dt_info() allows you to set the default
conversion modes for DATETIME values, and
lets you query the locale database for
names for dateparts.
To set the default conversion you call
cs_dt_info() with a $type parameter of
CS_DT_CONVFMT, and pass the conversion
style you want as the last parameter:
cs_dt_info(CS_SET, CS_DT_CONVFMT, CS_UNUSED, CS_DATES_LONG);
See Table 2-26 in the Open Client and Open
Server Common Libraries Reference Manual
for details of other formats that are
available.
You can query a datepart name by doing
something like:
cs_dt_info(CS_GET, CS_MONTH, 3, $buf);
print "$buf\n"; # Prints 'April' in the default locale
Again see the entry for cs_dt_info() in
Chapter 2 of the Open Client and Open
Server Common Libraries Reference Manual
for details.
Michael
--
Michael Peppler -||- Data Migrations Inc.
mpeppler@peppler.org -||- http://www.mbay.net/~mpeppler
Int. Sybase User Group -||- http://www.isug.com
Sybase on Linux mailing list: ase-linux-list@isug.com
|