SQL Server Date Formats — ffffd

前端 未结 6 532
迷失自我
迷失自我 2021-01-13 19:11

How do I get the day of the week (in ffffd format, so Mon, Tue etc.) in SQL ? I don\'t see anything about it in the CAST and CONVERT documentation..

6条回答
  •  独厮守ぢ
    2021-01-13 19:55

    For SQL Server 2012+:

    SELECT FORMAT(GETUTCDATE(),'ffffd') AS ShortDayName
    

    This is much cleaner than a substring solution. The FORMAT() function can also be passed a culture for locale-aware formatting.

    Note that this works for other date parts, such as month:

    SELECT FORMAT(GETUTCDATE(),'MMM') AS ShortMonthName
    

    FORMAT() Reference

提交回复
热议问题