MS SQL compare dates?

前端 未结 5 2056
-上瘾入骨i
-上瘾入骨i 2020-12-08 01:30

I have 2 dates (datetimes):

date1 = 2010-12-31 15:13:48.593
date2 = 2010-12-31 00:00:00.000

Its the same day, just different times. Com

5条回答
  •  Happy的楠姐
    2020-12-08 02:01

    The simple one line solution is

    datediff(dd,'2010-12-31 15:13:48.593','2010-12-31 00:00:00.000')=0
    
    datediff(dd,'2010-12-31 15:13:48.593','2010-12-31 00:00:00.000')<=1
    
    datediff(dd,'2010-12-31 15:13:48.593','2010-12-31 00:00:00.000')>=1
    

    You can try various option with this other than "dd"

提交回复
热议问题