Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to Convert in Timestamp

 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

I am trying to convert the given String in timestamp format using PL/SQL Language.

Here is the sql query i wrote to convert string in timestamp. But I am getting error "Ora-01810: format code appears twice" while executing the query. Please help me out and let me know what I am doing wrong while executing the query:

select to_timestamp('01/03/2007 12:01:22', 'MM/DD/YYYY HH24:MM:SS') from dual
and this one too

select to_timestamp('01/03/2007 12:01:22', 'MM/DD/YYYY HH12:MM:SS') from dual

At the same time I am able to execute the follwoing query:

select to_timestamp('2003/DEC/13 20:13:18', 'YYYY/MONTH/DD HH24:MI:SS') from dual

DO let me know where I am going wrong.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like you are defining the months twice in your format. Check the docs, minutes are MI.
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Sturrock:
Looks like you are defining the months twice in your format. Check the docs, minutes are MI.


Oops Sorry.. i did it again....

Thanks Paul Sturrock..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic