How to get month from To_CHAR in oracle?

Viewed 209

I'm using To_Char to convert a date to a string in the following format :

To_char(Date,'DD Month YYYY HH24:MI')

This works great however it returns the month with some spaces. I guess it's desgined such that all the month strings have the same lenght:

Current result

01 January  2020 13:15
01 February 2020 13:15
01 March    2020 13:15       << Spaces after the month string
01 April    2020 13:15       << Spaces after the month string
01 May      2020 13:15       << Spaces after the month string
01 June     2020 13:15       << Spaces after the month string

Desired result

01 January 2020 13:15
01 February 2020 13:15
01 March 2020 13:15       << No spaces after the month string
01 April 2020 13:15       << No spaces after the month string
01 May 2020 13:15         << No spaces after the month string
01 June 2020 13:15        << No spaces after the month string

Does anyone know how to achieve that please directly from To_char function ? (without doing some specific string replacements like replace(To_char(Date,'DD Month YYYY HH24:MI'),' double spaces ',' single space ');

Thanks Cheers,

1 Answers

You can use the fm modifier on month:

select to_char(sysdate,'DD FMMonth YYYY HH24:MI')
from dual
Related