Answered date in MMYY format

  • Wednesday, February 25, 2009 11:26 PM
     
     
    Hi ,
    Can any one tell me how to write date time in Month and Year format?
    Ex;
    01.01.09 00:00:00  should be Jan 2009

    Thanks
    shamen

All Replies

  • Wednesday, February 25, 2009 11:35 PM
     
     

    Look at the DATEPART in BOL

  • Thursday, February 26, 2009 2:16 AM
    Moderator
     
     Answered Has Code
     
    declare @dt DATETIME  
    SET @dt='01.01.09 00:00:00' 
     
    SELECT STUFF(CONVERT(VARCHAR(12),@dt,107),4,4, ' ') as MMYY 


    --Jan  2009
  • Thursday, February 26, 2009 4:10 AM
    Moderator
     
     Answered
     

    SELECT RIGHT(CONVERT(VARCHAR(12),getdate(),106),8)


    Mangal Pardeshi
    SQL With Mangal
    Technical Skill is the mastery of complexity, while Creativity is the master of simplicity
  • Friday, February 27, 2009 1:42 AM
    Moderator
     
     

    Hi shamen,

    limno and Magal's answer is good.

    But if you are not in the location "us_english", please add " SET LANGUAGE 'us_english' " at the begin of the statement.

    Thanks,

    Jin


    Jin Chen - MSFT