Re: [PHP-DB] Retrieving a date from Oracle. Please help!

2002-05-24 Thread max

Thank you ALL!
It turned out that setting NLS_DATE_FORMAT environment variable is enough to
solve the problem. It's possible to get it worked right from PHP code, for
instance:

putenv("NLS_DATE_FORMAT=HH24:MI:SS DD.MM.");

PS>
TO_DATE function didn't help
I didn't try to ALTER SESSION or change Oracle ini params

Maxim

Best regards,
Maxim Bubnov,
Software Engineer,
Stelt Telecom NN

- Original Message -
From: "Ford, Mike [LSS]" <[EMAIL PROTECTED]>
To: "'maxim'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, May 23, 2002 8:39 PM
Subject: RE: [PHP-DB] Retrieving a date from Oracle. Please help!


> > -Original Message-
> > From: maxim [mailto:[EMAIL PROTECTED]]
> > Sent: 23 May 2002 17:00
> >
> > Hi all!
> > The problem is I can't get expected datetime value from
> > SELECT query on
> > Oracle table that has a field of type DATE. Seems like
> > datetime looses its
> > time part.
>
> The default format for dates returned from Oracle tends to be something
like 'DD-MON-YY', thus giving only a short-form date.  There are several
ways of changing this:
>
>   * Use the TO_DATE function in your select, e.g.
> $sql = "select TO_DATE(A_DATE, 'DD-Mon- HH24:MI:SS') as
DATE_TIME from A_TABLE"
>
>   * Use ALTER SESSION to set the default format for the current session
(NOTE: I haven't tried this (yet!)):
> $stmt = OCIParse("ALTER SESSION SET NLS_DATE_FORMAT = 'DD-Mon-
HH24:MI'");
> OCIExecute($stmt);
>
>   * Change the default value of the Oracle initialization parameter
NLS_DATE_FORMAT (I haven't tried this either, as I don't have administrative
control of my Oracle database!).
>
> Mike
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Retrieving a date from Oracle. Please help!

2002-05-23 Thread Michael Bretterklieber

Hi,

ALTER SESSION SET NLS_DATE_FORMAT="-MM-DD HH24:MI:SS"

bye,

maxim wrote:
> Hi all!
> The problem is I can't get expected datetime value from SELECT query on
> Oracle table that has a field of type DATE. Seems like datetime looses its
> time part.
> 
> The code is like as follows:
> ...
> $sql = "select * from A_TABLE";
> ora_parse($curs, $sql);
> ora_exec($curs);
> ...
> ora_fetch_into($cursor, $r, ORA_FETCHINTO_NULLS);
> foreach ($r as $key => $value) {
> print "$key => $value \n";
> }
> ...
> 
> This displays date part only. May be special PHP or Oracle ini parameters or
> environment vars required? Any help appreciated.
> 
> Best regards,
> Maxim Bubnov,
> Software Engineer,
> Stelt Telecom NN
> 
> 
> 


-- 
--
--
E-mail: [EMAIL PROTECTED]

JAWA Management Software GmbH
Liebenauer Hauptstr. 200
A-8041 GRAZ
Tel: ++43-(0)316-403274-12
Fax: ++43-(0)316-403274-10
GSM: ++43-(0)676-93 96 698
homepage: http://www.jawa.at
- privat ---
E-mail:   [EMAIL PROTECTED]
homepage: http://www.inode.at/mbretter
--



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Retrieving a date from Oracle. Please help!

2002-05-23 Thread Ford, Mike [LSS]

> -Original Message-
> From: maxim [mailto:[EMAIL PROTECTED]]
> Sent: 23 May 2002 17:00
> 
> Hi all!
> The problem is I can't get expected datetime value from 
> SELECT query on
> Oracle table that has a field of type DATE. Seems like 
> datetime looses its
> time part.

The default format for dates returned from Oracle tends to be something like 
'DD-MON-YY', thus giving only a short-form date.  There are several ways of changing 
this:

  * Use the TO_DATE function in your select, e.g.
$sql = "select TO_DATE(A_DATE, 'DD-Mon- HH24:MI:SS') as DATE_TIME from 
A_TABLE"

  * Use ALTER SESSION to set the default format for the current session (NOTE: I 
haven't tried this (yet!)):
$stmt = OCIParse("ALTER SESSION SET NLS_DATE_FORMAT = 'DD-Mon- HH24:MI'");
OCIExecute($stmt);

  * Change the default value of the Oracle initialization parameter NLS_DATE_FORMAT (I 
haven't tried this either, as I don't have administrative control of my Oracle 
database!).

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Retrieving a date from Oracle. Please help!

2002-05-23 Thread Ford, Mike [LSS]

> -Original Message-
> From: maxim [mailto:[EMAIL PROTECTED]]
> Sent: 23 May 2002 17:00
> 
> Hi all!
> The problem is I can't get expected datetime value from 
> SELECT query on
> Oracle table that has a field of type DATE. Seems like 
> datetime looses its
> time part.

The default format for dates returned from Oracle tends to be something like 
'DD-MON-YY', thus giving only a short-form date.  There are several ways of changing 
this:

  * Use the TO_DATE function in your select, e.g.
$sql = "select TO_DATE(A_DATE, 'DD-Mon- HH24:MI:SS') as DATE_TIME from 
A_TABLE"

  * Use ALTER SESSION to set the default format for the current session (NOTE: I 
haven't tried this (yet!)):
$stmt = OCIParse("ALTER SESSION SET NLS_DATE_FORMAT = 'DD-Mon- HH24:MI'");
OCIExecute($stmt);

  * Change the default value of the Oracle initialization parameter NLS_DATE_FORMAT (I 
haven't tried this either, as I don't have administrative control of my Oracle 
database!).

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Retrieving a date from Oracle. Please help!

2002-05-23 Thread maxim

Hi all!
The problem is I can't get expected datetime value from SELECT query on
Oracle table that has a field of type DATE. Seems like datetime looses its
time part.

The code is like as follows:
...
$sql = "select * from A_TABLE";
ora_parse($curs, $sql);
ora_exec($curs);
...
ora_fetch_into($cursor, $r, ORA_FETCHINTO_NULLS);
foreach ($r as $key => $value) {
print "$key => $value \n";
}
...

This displays date part only. May be special PHP or Oracle ini parameters or
environment vars required? Any help appreciated.

Best regards,
Maxim Bubnov,
Software Engineer,
Stelt Telecom NN



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php