0

Query:

select date,TO_CHAR(date,'dd/MM/yyyy HH24:mm:ss')  from user.table  where rownum<10;


02-08-18 05:21:02.301000000 PM  02/08/2018 17:08:02

Problem is minutes in above time are different 'mm' loses the precision of minutes and probably providing some garbage value. How do I format dates without losing precision?

  • Please explain the downvote.. – Sachin Verma Sep 24 '18 at 16:41
  • 1
    Some self-righteous Oracle guru probably never accidentally typed mm for minutes instead of mi -- I often make this mistake even after years using Oracle. – Mark Stewart Sep 25 '18 at 17:22
7

As documented in the manual you have to use mi for minutes. mm is for the month number

select date,
       TO_CHAR(date,'dd/MM/yyyy HH24:mi:ss')  
from user.table 
where rownum<10;
  • so MM or mm are same ie cases doesnt matter? – Sachin Verma Sep 24 '18 at 16:57
  • 1
    Case doe not matter for format characters that produce numbers, but those that produce characters, such as Mon or 'Month` case matters; Mon produces the abbreviated name of the month in Mixed case, such as Jan and MON would produce JAN – Mark Stewart Sep 25 '18 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.