How to compare just the date part and not the time of two Dates?

后端 未结 6 1612
南旧
南旧 2020-12-29 21:30

I want to compare just the date part (and Not the time) of two VB.NET Date objects. Is there a way to do that?

6条回答
  •  半阙折子戏
    2020-12-29 22:00

    You could also use TimeSpan

    Dim ts As TimeSpan
    ts = dt1 - dt2
    

    ts.Days will now have the difference of the two dates as whole days.

提交回复
热议问题