How to convert a datetime to string in T-SQL

前端 未结 9 1379
没有蜡笔的小新
没有蜡笔的小新 2020-12-13 03:19

I\'m surprised not to be able to find this question here already.

I have a date time var and I want to convert it to a string so that I can append it to another stri

9条回答
  •  情书的邮戳
    2020-12-13 03:53

    The following query will get the current datetime and convert into string. with the following format
    yyyy-mm-dd hh:mm:ss(24h)

    SELECT convert(varchar(25), getdate(), 120) 
    
    • SQLFiddle Demo
    • SQL Server Date Formats

提交回复
热议问题