Solved

Date format in oracle

Posted on 2009-05-05
9
1,055 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
 
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

932 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now