SQL查询转换月份

时间:2012-08-06 04:08:25

标签: sql sql-server

下面的查询以小写形式返回日期作为月份,我需要以大写字母表示的月份,我们非常感谢任何帮助。目前2012年8月8日,我需要2012年8月8日。

Select 
    RTrim(Right(MTRL.MTRL_NBR, 9)) As MTRL_NBR, 
    RTrim(PROD_ORDR.PROD_ORDR_NBR) As ORDER_NBR, 
    RTrim(PROD_ORDR.BTCH_NBR) As BATCH_NBR, 
    RTrim(PROD_ORDR.RVSN_LVL) As REV_LVL, 
    Convert(VARCHAR(11),PROD_ORDR.ACT_RLSE_DT,106) As RELEASE_DATE 
From 
    MPM.DBO.PROD_ORDR 
Inner Join MPM.DBO.MTRL 
    On PROD_ORDR.MTRL_OID = MTRL.OID 
Where PROD_ORDR.PROD_ORDR_NBR = 000104007817

3 个答案:

答案 0 :(得分:1)

Select  
    RTrim(Right(MTRL.MTRL_NBR, 9)) As MTRL_NBR,  
    RTrim(PROD_ORDR.PROD_ORDR_NBR) As ORDER_NBR,  
    RTrim(PROD_ORDR.BTCH_NBR) As BATCH_NBR,  
    RTrim(PROD_ORDR.RVSN_LVL) As REV_LVL,  
    UPPER(Convert(VARCHAR(11),PROD_ORDR.ACT_RLSE_DT,106)) As RELEASE_DATE  
From  
    MPM.DBO.PROD_ORDR  
Inner Join MPM.DBO.MTRL  
    On PROD_ORDR.MTRL_OID = MTRL.OID  
Where PROD_ORDR.PROD_ORDR_NBR = 000104007817 

答案 1 :(得分:1)

如果您使用的是sql server,则可以使用Upper()函数

Select RTrim(Right(MTRL.MTRL_NBR, 9)) As MTRL_NBR, 
        RTrim(PROD_ORDR.PROD_ORDR_NBR) As ORDER_NBR, 
        RTrim(PROD_ORDR.BTCH_NBR) As BATCH_NBR, RTrim(PROD_ORDR.RVSN_LVL) As REV_LVL, 
        Upper(Convert(VARCHAR(11),PROD_ORDR.ACT_RLSE_DT,106)) As RELEASE_DATE From MPM.DBO.PROD_ORDR Inner Join MPM.DBO.MTRL On PROD_ORDR.MTRL_OID = MTRL.OID Where PROD_ORDR.PROD_ORDR_NBR = 000104007817

答案 2 :(得分:0)

使用UPPER函数为您完成。

SELECT  RTrim(Right(MTRL.MTRL_NBR, 9)) As MTRL_NBR,  
        RTrim(PROD_ORDR.PROD_ORDR_NBR) As ORDER_NBR,  
        RTrim(PROD_ORDR.BTCH_NBR) As BATCH_NBR,  
        RTrim(PROD_ORDR.RVSN_LVL) As REV_LVL,  
        UPPER(Convert(VARCHAR(11),PROD_ORDR.ACT_RLSE_DT,106)) As RELEASE_DATE  
FROM    MPM.DBO.PROD_ORDR  
           INNER JOIN MPM.DBO.MTRL  
              ON PROD_ORDR.MTRL_OID = MTRL.OID  
WHERE   PROD_ORDR.PROD_ORDR_NBR = 000104007817