Home » SQL & PL/SQL » SQL & PL/SQL » Date Format
Date Format [message #214609] Wed, 17 January 2007 04:34 Go to next message
emadbsb
Messages: 334
Registered: May 2005
Location: egypt
Senior Member


Hii All

I want to format the date represented to be containing hour , minutes , seconds

see this please

 SELECT TO_DATE (LASTUPDATE,'DD-MM-YYYY HH24:MI:SS') FROM GCUXXXXXX
 WHERE CODE = 'fex0185'


result is
17-JAN-07



I want the result to be something like 17-10-2007 10:45:21


Can i do that??

Thanks for everyone helped and helping me

Re: Date Format [message #214613 is a reply to message #214609] Wed, 17 January 2007 04:53 Go to previous messageGo to next message
romi
Messages: 67
Registered: October 2006
Member

Try it:-


select to_char(sysdate,'DD/MM/YYYY HH:MI:SS') from dual;
Re: Date Format [message #214614 is a reply to message #214609] Wed, 17 January 2007 04:53 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
It's all just a case of setting the format mask that the date will display in.

You can either use to_char to convert the data to a specific format, or set the nls_date_format parameter which controls how dates are displayed by default.
SQL> select sysdate from dual;

SYSDATE
---------
17-JAN-07

SQL> select to_char(sysdate,'DD-MM-YYYY HH24:MI:SS') from dual;

TO_CHAR(SYSDATE,'DD
-------------------
17-01-2007 10:52:27

SQL> alter session set nls_date_format='DD-MM-YYYY HH24:MI:SS'
  2  ;

Session altered.

SQL> select sysdate from dual;

SYSDATE
-------------------
17-01-2007 10:52:53
Re: Date Format [message #214617 is a reply to message #214609] Wed, 17 January 2007 04:55 Go to previous messageGo to next message
romi
Messages: 67
Registered: October 2006
Member

Correct one is:-



select to_char(date,'DD-MM-YYYY HH24:MI:SS') from dual;







Re: Date Format [message #214660 is a reply to message #214609] Wed, 17 January 2007 07:18 Go to previous messageGo to next message
raj_2005
Messages: 5
Registered: February 2006
Location: Pune
Junior Member
you can use

to_char instead of to_date..

Regards,
Raj
Re: Date Format [message #214661 is a reply to message #214614] Wed, 17 January 2007 07:20 Go to previous messageGo to next message
raj_2005
Messages: 5
Registered: February 2006
Location: Pune
Junior Member
You can go ahead upper suggested solution.
It would resolve you problem.

Raj
Re: Date Format [message #214668 is a reply to message #214661] Wed, 17 January 2007 07:40 Go to previous message
joy_division
Messages: 4640
Registered: February 2005
Location: East Coast USA
Senior Member
Why do we have three more responses after the correct one by JRowBottom?
Previous Topic: Quick question about comparisons.
Next Topic: Merging two flat files
Goto Forum:
  


Current Time: Tue Dec 06 12:14:13 CST 2016

Total time taken to generate the page: 0.12757 seconds