Re: Date Format for INFORMIX using DBI



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



Relevant Pages

  • can I format dates older than 1900
    ... I manage a database for my church and i ran into a problem. ... date to YYYY/MM/DD before the year 1900? ... I changed the format in my file but ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Protel 2004 answer to Brad Velander.
    ... Sorry, you misunderstand me, I mean to say that jump from 99SE to 2004 XP ... you don't have the same format with one database will all the documents. ... Well you said that you can export file format more recent than AUTOCAD 14 ... key/mouse click you press because I don't know how to do that with Protel ...
    (sci.electronics.cad)
  • Re: Combo box not finding record... sometimes
    ... Try the Format option last. ... Private Sub cboLnNum_AfterUpdate ... when I change the data type from Double to Long Integer the database ...
    (microsoft.public.access.formscoding)
  • Re: Error Message: Cant find Installable ISAM
    ... The database is residing on my machine, ... Error Message = "Couldn't find Installable ISAM" ... Connect property set = Access ... Access 2002/2003 format and tried this as a possibility, ...
    (microsoft.public.vb.database)
  • Re: What program is best for large inventory?
    ... put the information in the format that I want. ... down into several sub groups and some even further. ... The learning curve for general database concepts is moderate. ...
    (microsoft.public.office.misc)