Oracle Date TO_CHAR('Month DD, YYYY') has extra spaces in it

contactmatt picture contactmatt · Aug 23, 2011 · Viewed 119.5k times · Source

When I do...

Select TO_CHAR (date_field, 'Month DD, YYYY')
from...

I get the following:

July      01, 2011
April     01, 2011
January   01, 2011

Why are there extra spaces between my month and day? Why doesn't it just put them next to each other?

Answer

NullUserException picture NullUserException · Aug 23, 2011

Why are there extra spaces between my month and day? Why does't it just put them next to each other?

So your output will be aligned.

If you don't want padding use the format modifier FM:

SELECT TO_CHAR (date_field, 'fmMonth DD, YYYY') 
  FROM ...;

Reference: Format Model Modifiers