Skip to content
Advertisement

TO_CHAR from Date data type output difference

select CREATED_DATE,to_char(CREATED_DATE, 'YYYY-MM-DD HH24:MM') CREATED_DATE_2 from MY_TABLE;

CREATED_DATE            CREATED_DATE_2 
4/20/2020 1:44:57 AM    2020-04-20 01:04
4/20/2020 6:45:55 AM    2020-04-20 06:04
4/21/2020 5:32:57 AM    2020-04-21 05:04
4/21/2020 5:33:45 AM    2020-04-21 05:04

Not sure why I see this big difference when using to_char function

Advertisement

Answer

You are using the format of month MM instead of Minutes MI ,Please use the below

  select CREATED_DATE,to_char(CREATED_DATE, 'YYYY-MM-DD HH24:MI') CREATED_DATE_2 from MY_TABLE;
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement