Solved

Date format in oracle

Posted on 2009-05-05
9
1,056 Views
Last Modified: 2013-12-19
Aug 28 2006  5:12:42:000AM

How to specify the date format..?

"Mon dd yyyy hh:mi:ss.....AM"

i tried FF3 after the seconds field but not getting recognized ?
0
Comment
Question by:vishali_vishu
  • 5
  • 2
9 Comments
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24309313
date does not allow FF3, you must use timestamp if you want that format, or drop the ff3 since DATE only stores seconds. SYSTIMESTAMP is more granular.


select to_char(systimestamp, 'MON dd yyyy hh:mi:ss.ff3') from dual;
0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24309326
Sorry, typo. I meant TIMESTAMP is more granular
0
 
LVL 1

Author Comment

by:vishali_vishu
ID: 24309549
How to change a varchar in that format to timestamp.?

something like to_date ? what's the function used to convert.
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 40

Accepted Solution

by:
mrjoltcola earned 250 total points
ID: 24309649
select to_timestamp('MAY 05 2009 05:25:42.032', 'MON dd yyyy hh:mi:ss.ff3') from dual;
0
 
LVL 5

Assisted Solution

by:tzxie2000
tzxie2000 earned 250 total points
ID: 24310688
Like this:
SELECT TO_TIMESTAMP('MAY 05 2009 05:25:42.032','MON DD yyyy HH:MI:SS,ff3',
                    'NLS_DATE_LANGUAGE=american')
  FROM DUAL;
0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24310820
You don't normally need to hardcode like that, you should use the Oracle environment. It will use your database/instance/session NLS parameters for that. The only time you would hardcode that, or would provide it explicitly would be in case of a international web application that stores custom language/timezone for each user and your web app is pooling database connections where you cannot set it at the session level.
0
 
LVL 5

Expert Comment

by:tzxie2000
ID: 24311180
Agree.
The difference is SS,ff3
0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24354741
@vishali, can you explain why you accepted the latter solution? Both solutions produce acceptable results and answered your question, however the original question was answered in my very first reply.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Via a live example, show how to take different types of Oracle backups using RMAN.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question