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?

2
  • Please explain the downvote.. Commented Sep 24, 2018 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. Commented Sep 25, 2018 at 17:22

1 Answer 1

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;
2
  • so MM or mm are same ie cases doesnt matter? Commented Sep 24, 2018 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 Commented Sep 25, 2018 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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