Re: Date Format for INFORMIX using DBI
- From: jonathan.leffler@xxxxxxxxx (Jonathan Leffler)
- Date: Tue, 17 May 2005 01:01:33 -0700
On 5/16/05, Nitin Nair <NNair@xxxxxxxxxxxxxxxx> wrote:
> I am using the DBI to extract some data from the underlying Informix
> Database. Even after doing the following when I am printing the value
> for $start_date, it is in the format 'dd/mm/yyyy' instead of the
> expected 'yyyy/mm/dd'. Can any of you advise as to why this is
> happening..??
Your locale is such that the dates are being formatted in dd/mm/yyyy
order, or you have DBDATE=dmy4/ in your environment.
> $sth = $dbh->prepare("select company,customer, pur_order, ref,
> start_date, end_date, limit, on_billing, page_break, cons_usage,
> cons_items, memo, pref_date, first_bill, igpm_adv,comment1, comment2,
> comment3 from purchase_order");
>
> ($rv = $sth->execute);
> $sth->bind_col(5, \$start_date, { TYPE => DBI::SQL_DATE });
> while (($company,$customer, $pur_order, $ref,$limit, $on_billing,
> $page_break, $cons_usage, $cons_items, $memo, $first_bill,
> $igpm_adv,$comment1, $comment2, $comment3 ) = $sth->fetchrow)
> {
>
> print "\nStart Date is : ${start_date}\n" ;
> }
There are various ways to get the more orthodox (non-localized) date
format; which you choose depends on your rules of engagement - what's
permitted in your environment. The fact that you're using
DBI::SQL_DATE suggests that you are trying to be database agnostic,
which will make life harder. The easiest fix is to set DBDATE=y4md-
in the environment (possibly in the Perl script before you do
DBI->connect and thereby load the DBD::Informix driver). Other
options include casting the return value to DATETIME YEAR TO DAY,
using TO_CHAR() on the DATE, and so on.
--
Jonathan Leffler <jonathan.leffler@xxxxxxxxx> #include <disclaimer.h>
Guardian of DBD::Informix - v2005.01 - http://dbi.perl.org
"I don't suffer from insanity - I enjoy every minute of it."
.
- References:
- Date Format for INFORMIX using DBI
- From: Nitin Nair
- Date Format for INFORMIX using DBI
- Prev by Date: Re: DBD::Oracle on MacOSX using Instant Client
- Next by Date: RE: [dbi] Segmentation fault on RHEL4
- Previous by thread: Date Format for INFORMIX using DBI
- Index(es):
Relevant Pages
|
|