php-db | 2001041

Re: [PHP-DB] date_format for Oracle From: Brian S. Dunworth (brian <email protected>)
Date: 04/12/01

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 <email protected>>
  -------------------------------------

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>