Compare time part of DateTime data type in SQL Server 2005

前端 未结 6 1922
梦谈多话
梦谈多话 2021-01-02 07:41

How can I compare only the time portion of a DateTime data type in SQL Server 2005? For example, I want to get all records in which MyDateField is after a specific time. The

6条回答
  •  别那么骄傲
    2021-01-02 07:52

    convert(varchar(10),MyDate,108)

    This gives you a time string of format HH:MM:SS.

    You can then do any comparison you want with it

提交回复
热议问题