Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date format conversion

Status
Not open for further replies.

SkyHigh

Technical User
May 30, 2002
309
CA
Hi

I have to create a report where I have to show a date in a table with timezone, but when I query the date field it shows date as :

11-MAY-01

While I want it as : ( Time zone should be UTC )

2001-05-11 23:09:09+00 (This is just an example)

And also how can I add report heading using sqlplus

Your help would be much appreciated
Brenda
 
Oracle has a very robust set of date/time functions. The database has various defaults like dd-Mon-yy for a date. You can change from the default via using a function (like TO_CHAR or TO_DATE) or alter the session using an ALTER SESSION Looks like here you want something like (from Oracle's SQL Reference) :

The following example illustrates that CURRENT_TIMESTAMP is sensitive to the session time zone:

ALTER SESSION SET TIME_ZONE = '-5:0';
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
SELECT SESSIONTIMEZONE, CURRENT_TIMESTAMP FROM DUAL;

SESSIONTIMEZONE CURRENT_TIMESTAMP
--------------- ---------------------------------------------------
-05:00 04-APR-00 01.17.56.917550 PM -05:00

ALTER SESSION SET TIME_ZONE = '-8:0';
SELECT SESSIONTIMEZONE, CURRENT_TIMESTAMP FROM DUAL;

SESSIONTIMEZONE CURRENT_TIMESTAMP
--------------- ----------------------------------------------------
-08:00 04-APR-00 10.18.21.366065 AM -08:00


Check out this url to research time/date functions:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top