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

后端 未结 6 1496
南旧
南旧 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:04

    Dim date1, date2 As Date
    date1 = Date.Parse(dtpStart.Text)
    date2 = Date.Parse(dtpEnd.Text)
    If (DateTime.Compare(date1, date2) > 0) Then ' which means ("date1 > date2") 
        MessageBox.Show("يجب تحديد  الفترة للتاريخ بشكل صحيح  ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading)
        Exit Sub
    End If
    

提交回复
热议问题