date function [message #484486] |
Wed, 01 December 2010 01:02  |
shaz
Messages: 182 Registered: June 2009
|
Senior Member |
|
|
hello gurus,
i want to show the date exactly in following format:
00:16:15 Wed 1st Dec 2010
I have tried :
select to_char(to_date('01/12/2010 00:16:15' , 'dd/mm/yyyy hh24:mi:ss'), 'hh24:mi:ss Day dd Mon yyyy')
from dual
Result it is giving
00:16:15 Wednesday 01 Dec 2010
Please help:
How to show date in form 1st 2nd 3rd and so on?
How to show Abbreviated name of the day?
|
|
|
|
|
|
Re: date function [message #484505 is a reply to message #484504] |
Wed, 01 December 2010 03:14   |
shaz
Messages: 182 Registered: June 2009
|
Senior Member |
|
|
Thanks Sriram for the link.
I am using it in form.
I want to read the date from the same format.
I am using:
select to_date ('00:16:15 Wed 10th Dec 2010','hh24:mi:ss Dy fmddth Mon rrrr')
from dual
This code is giving error. Please help.
[Updated on: Wed, 01 December 2010 04:08] Report message to a moderator
|
|
|
|
|
|
|
|
|
Re: date function [message #484610 is a reply to message #484541] |
Thu, 02 December 2010 00:25   |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
That might not work for you, because you use fmddth, where Barbara used ddth for the day-of-month part. You will have to put some extra effort in it.
In short, human readable dates are not meant to be converted into machine readable dates. Can't you just use dd-mm-yyyy as input format? I bet most datatypers would rather type that than the extensive format you use.
|
|
|
|
Re: date function [message #484620 is a reply to message #484619] |
Thu, 02 December 2010 01:16  |
 |
Michel Cadot
Messages: 68767 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Another way is:
SQL> with
2 data as (
3 select to_char (sysdate + rownum - 3, 'hh24:mi:ss Dy fmddth Mon rrrr') test_col
4 from dual
5 connect by level <= 7
6 )
7 select to_date(regexp_replace(test_col,'(th|st|nd|rd)',''),'hh24:mi:ss Dy dd Mon rrrr')
8 from data
9 /
TO_DATE(REG
-----------
30-NOV-2010
01-DEC-2010
02-DEC-2010
03-DEC-2010
04-DEC-2010
05-DEC-2010
06-DEC-2010
Regards
Michel
|
|
|