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:
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
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,
You can use the fm
modifier on month
:
select to_char(sysdate,'DD FMMonth YYYY HH24:MI')
from dual
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.