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

前端 未结 6 1692
渐次进展
渐次进展 2020-12-03 10:18

When I do...

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

I get the following:

July      01, 2011
April     01,          


        
6条回答
  •  暖寄归人
    2020-12-03 10:59

    if you use 'Month' in to_char it right pads to 9 characters; you have to use the abbreviated 'MON', or to_char then trim and concatenate it to avoid this. See, http://www.techonthenet.com/oracle/functions/to_char.php

    select trim(to_char(date_field, 'month')) || ' ' || to_char(date_field,'dd, yyyy')
      from ...
    

    or

    select to_char(date_field,'mon dd, yyyy')
      from ...  
    

提交回复
热议问题