SQL Query - Change date format in query to DD/MM/YYYY

后端 未结 5 1035
悲哀的现实
悲哀的现实 2021-02-19 06:13

What I\'m trying to achieve is fairly straight forward, to get one date format to another;

From This: Jan 30 2013 12:00:00:000AM To This: DD/MM/YYYY

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-19 06:29

    If I understood your question, try something like this

    declare @dd varchar(50)='Jan 30 2013 12:00:00:000AM'
    
    Select convert(varchar,(CONVERT(date,@dd,103)),103)
    

    Update

    SELECT
    PREFIX_TableName.ColumnName1 AS Name,
    PREFIX_TableName.ColumnName2 AS E-Mail,
    convert(varchar,(CONVERT(date,PREFIX_TableName.ColumnName3,103)),103) AS TransactionDate,
    PREFIX_TableName.ColumnName4 AS OrderNumber
    

提交回复
热议问题