Re: Oracle date conversion
| From: | David C. Norris | Date: | Fri, 11 Jan 2002 21:45:23 +0000 |
| Subject: | Re: Oracle date conversion | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-15676@lists.php.net to get a copy of this message | ||
Thanks for your response. When I use SQL*Plus, I get full date+time. I also get a full datetime
from cx_Oracle (a
Python module). Is this then a default _PHP_ behavior when querying an Oracle db? Why not return
the full info?
Ordinarily, I would not complain about the small rewrite you suggest, but my application is an SQL
query window in the
browser, aimed at users who are not SQL enthusiasts.
Thanks again,
David
"Ford, Mike [LSS]" wrote:
> > -----Original Message-----
> > From: David C. Norris [mailto:dnorris@mitre.org]
> > Sent: 26 December 2001 17:00
> >
> > Oracle DATEs are retrieved (by ora_fetch_into($cursor, $row,
> > ORA_FETCHINTO_NULLS), for example) as plain dates (e.g., '26-DEC-01'),
> > losing the time of day (as in '26-DEC-01 12:34:56'). Is this
> > a bug?
>
> No, this is the default ORACLE format for retrieved dates.
>
> > Is
> > there a workaround that doesn't involve rewriting the query?
>
> No, but modifying the query to use a date format is actually the best solution. This would
> give you something like:
>
> SELECT TO_CHAR(DATE, 'DD-MON-YY HH:MI:SS') AS DATE_TIME FROM TBL
>
> Look up the definition of the TO_CHAR function for the full list of format elements available
> for formatting DATEs.
>
> 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: m.ford@lmu.ac.uk
> Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211