Re: date_format for Oracle

From: Date: Thu, 12 Apr 2001 16:03:54 +0000
Subject: Re: date_format for Oracle
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-8521@lists.php.net to get a copy of this message
At 10:12 PM 4/11/01 +0000, Richard Crawford wrote:
This isn't strictly a PHP question, I suppose... but is anyone aware of a date_format function for Oracle comparable to MySQL's date_format() function?
I'm not familiar at all with MySQL nor its date_format() function, but Oracle has two functions for changing the DATE type to CHAR strings and vice-versa. Take a look at the TO_CHAR and TO_DATE functions in Oracle (in the online help pages, if they were installed, or on the documentation CDROM) example:
       select to_char(date_field,'DD-MON-YYYY HH24:MI:SS')
          from table1
          where rownum < 5;
output:
       26-MAR-2001 18:09:59
       26-MAR-2001 18:09:59
       26-MAR-2001 18:09:59
       26-MAR-2001 18:09:59
example:
       select to_char(date_field,'Day, Month DD, YYYY HH:MI AM')
          from table1
          where rownum < 5;
output:
       Monday   , March     26, 2001 06:09 PM
       Monday   , March     26, 2001 06:09 PM
       Monday   , March     26, 2001 06:09 PM
       Monday   , March     26, 2001 06:09 PM
...there's a lot you can do with this formatting to get exactly what you want. Try typing "HELP FORMAT DATES" at the SQL prompt, and if you're lucky your DBA has installed the online help files. - Brian ------------------------------------- Brian S. Dunworth Sr. Software Development Engineer Oracle Database Administrator The Printing House, Ltd. (850) 875-1500 x225 <brian@theprintinghouse.com> -------------------------------------

« previous php.db (#8521) next »