Oracle日期TO_CHAR('月DD,YYYY')中有多余的空格 [英] Oracle Date TO_CHAR('Month DD, YYYY') has extra spaces in it
本文介绍了Oracle日期TO_CHAR('月DD,YYYY')中有多余的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我这样做时...
Select TO_CHAR (date_field, 'Month DD, YYYY')
from...
我得到以下信息:
July 01, 2011
April 01, 2011
January 01, 2011
为什么我的月份和日期之间有多余的空格?为什么不将它们并排放置?
推荐答案
如果在to_char中使用'Month',则将其填充为9个字符;您必须使用缩写的"MON"或to_char,然后对其进行修剪和连接以避免这种情况.参见 http://www.techonthenet.com/oracle/functions/to_char.php
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 ...
或
select to_char(date_field,'mon dd, yyyy')
from ...
这篇关于Oracle日期TO_CHAR('月DD,YYYY')中有多余的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文