sql server convert date to string MM/DD/YYYY

前端 未结 5 1592
误落风尘
误落风尘 2020-11-27 20:14

I am using SQL Server 2008.

I have the following:

    select convert(varchar(20),fmdate) from Sery

How do I convert the date to str

5条回答
  •  迷失自我
    2020-11-27 20:40

    As of SQL Server 2012+, you can use FORMAT(value, format [, culture ])

    Where the format param takes any valid standard format string or custom formatting string

    Example:

    SELECT FORMAT(GETDATE(), 'MM/dd/yyyy')
    

    Further Reading:

    • How to convert DateTime to VarChar
    • How to convert date to a format mm/dd/yyyy

提交回复
热议问题