dseigqk7443 2019-07-05 02:42
浏览 722
已采纳

将varchar转换为datetime以排序日期?

I want to try sorting dates but there are constraints, because those columns are varchar.

This existing data

enter image description here

This is the query that I test.

SELECT        PERIODE, RF, APPROVE_DATE
FROM            DLY_UPGRADE
WHERE        (SLP = '368') AND (CONVERT(datetime, APPROVE_DATE, 101) > '01/01/2017')

The error message :

enter image description here

  • 写回答

4条回答 默认 最新

  • doushui3061 2019-07-05 04:13
    关注

    If you are using SQL Server, try the following:

    SELECT        PERIODE, RF, APPROVE_DATE
    FROM            DLY_UPGRADE
    WHERE        (SLP = '368') AND (CONVERT(date, APPROVE_DATE, 103) > '2017-01-01')
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?