View Full Version : Check date is between 2 dates
av8tordude
01-12-2012, 11:48 PM
How can I check if a date falls within 2 dates.
i.e.
If 01/14/2011 is falls within 09/30/2010 and 10/01/2011 then
msgbox "Yes"
else
Msgbox "No"
Thanks for you help
Hi Aviator,
Something like:
Option Explicit
Sub example()
Dim dtmMyDate As Date
Const MIN_DATE = #9/30/2010#
Const MAX_DATE = #10/1/2011#
dtmMyDate = DateSerial(2011, 1, 14)
If dtmMyDate > MIN_DATE And dtmMyDate < MAX_DATE Then
MsgBox "Yep"
Else
MsgBox "Nope"
End If
End Sub
Hope that helps,
Mark
Bob Phillips
01-13-2012, 02:51 AM
By formula, a simple
=IF(AND(H2>=H3,H2<=H4),"Yes","No")
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.