How to query DATETIME field using only date in Microsoft SQL Server?

后端 未结 17 1955
隐瞒了意图╮
隐瞒了意图╮ 2020-12-02 06:31

I have a table TEST with a DATETIME field, like this:

ID NAME DATE
1 TESTING 2014-03-19 20:05:20.000
         


        
17条回答
  •  时光取名叫无心
    2020-12-02 07:06

    Test this query.

    SELECT *,DATE(chat_reg_date) AS is_date,TIME(chat_reg_time) AS is_time FROM chat WHERE chat_inbox_key='$chat_key' 
                             ORDER BY is_date DESC, is_time DESC
    

提交回复
热议问题