I have a situation here.. where in,.. i have a date and i need to verify/check wherther, this date falls between 2 given other dates.
Ex. I have a date as 10-feb-2007. And i need to check wherther this date is in between two other dates like.. 01-jan-2007 and 15-mar-2007.
Please help me.. if there is a function to check this thing.
Thank you in advance for ur help.
Well Please try this way. Hope this might help
Date1 = DateDiff("d","01-jan-2007","10-feb-2007")
Date2 = DateDiff("d","15-mar-2007","10-feb-2007")
if date1>0 and date2<0 then
msgbox "Date lies between"
msgbox "Date does not lie in between other two dates"
This will solve your problem.
I am not sure if there is any other function that will automatically do this
Thanks a bunch Ankush.
Will try it and let you know.
Post the exact code if you solve the problem
Convert all 3 values to Dates, then do a simple compare
ie. newDate = CDate(...)
lowerDate = CDate(...)
upperDate = CDate (...)
If newDate > lowerDate And newDate < upperDate Then