1. Casts cells from
dt
as
DateTime
datatype using CDATE()
2. Assumes that the two cells in
dt
only contain mm/dd/yyyy and do not contain any time data.
3. Saves only the date part of the current datetime in
dnow
variable using
.Date
property otherwise the compare for equal will fail.
Dim dfrom As DateTime = CDATE(dt.Rows(n - 1).Cells(2).Value)
Dim dto As DateTime = CDATE(dt.Rows(n - 1).Cells(3).Value)
Dim dnow As DateTime = Date.Now.Date
If dnow >= dfrom AndAlso dnow <= dto Then
MsgBox("Its working")
Else
MsgBox(" Epic Fail!!! ")
End If