Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Oracle Date format

Posted on 2014-02-14
3
Medium Priority
?
535 Views
Last Modified: 2014-02-26
Hi,
I have a varchar2 field that captures a values for dates like 17/01/2014 09:24. I wanted to convert this char value to a date format like mm/dd/yyyy without time stamp. I tried using to_date(charfield,'mm/dd/yyyy') but it is giving me a "not a valid month" error. Please help.
0
Comment
Question by:baralp
  • 3
3 Comments
 
LVL 78

Accepted Solution

by:
slightwv (䄆 Netminder) earned 2000 total points
ID: 39859993
regexp_substr(mycolumn,'^[^ ]+)

or
trunc(to_date('17/01/2014 09:24','DD/MM/YYYY HH24:MI')
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39860046
To be safe on the second one depending on how your default date format is:

to_char(to_date('17/01/2014 09:24','DD/MM/YYYY HH24:MI'),'DD/MM/YYYY')

>>'mm/dd/yyyy') but it is giving me a "not a valid mon

It appears your data isn't in mm/dd/yyy format but dd/mm/yyyy format.
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39860083
I should also point out that since your input data appears to be in dd/mm/yyyyy format, are you sure you want to convert it to "mm/dd/yyyy"

If you do, just change the format.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

782 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