date comparison

  • Thread starter Thread starter Brad
  • Start date Start date
B

Brad

I'm writing a program the needs to compare a user entered date (enterDate) in
one workbook with a date already present in another workbook(rawDate).
rawDate is formated "mm/dd/yyyy hh:mm:ss" the enterDate is formated
"mm/dd/yyyy". Any suggestions?
 
Hi Brad

Here is a hint

Sub CheckDate()

Dim rawDate As Date
Dim EnteredDate As Date

rawDate = ActiveCell.Value
EnteredDate = "10/14/2008"

If DateDiff("d", rawDate, EnteredDate) = 0 Then
MsgBox "Dates Match"
ElseIf DateDiff("d", rawDate, EnteredDate) > 0 Then
MsgBox "Entered Date is Greater than the Date"
ElseIf DateDiff("d", rawDate, EnteredDate) < 0 Then
MsgBox "Entered Date is Lesser than the Date"
End If
End Sub

Cheers
Shasur
 
Thanks, that worked great

Shasur said:
Hi Brad

Here is a hint

Sub CheckDate()

Dim rawDate As Date
Dim EnteredDate As Date

rawDate = ActiveCell.Value
EnteredDate = "10/14/2008"

If DateDiff("d", rawDate, EnteredDate) = 0 Then
MsgBox "Dates Match"
ElseIf DateDiff("d", rawDate, EnteredDate) > 0 Then
MsgBox "Entered Date is Greater than the Date"
ElseIf DateDiff("d", rawDate, EnteredDate) < 0 Then
MsgBox "Entered Date is Lesser than the Date"
End If
End Sub

Cheers
Shasur
 
Back
Top