Link to home
Start Free TrialLog in
Avatar of rwallacej
rwallacej

asked on

Check if date is next day

I've feeling this should be really obvious!

I have two dates. say date1, date2

How can I check if date2 is NEXT DAY of date1. so it ignores times
e.g.  if
date1 = 1/1/01 15:00
date2 = 2/1/01 12:00
result would give TRUE
ASKER CERTIFIED SOLUTION
Avatar of Lokesh B R
Lokesh B R
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rwallacej
rwallacej

ASKER

I should say that the date1 and date2 objects are of type DATETIME
is you example here not creating datetime objects so in comparison it will have Time in it too???
Hi,

Yes, If your date1 & date2 are of type DateTime then you can easily check the conditions.

In the above sample am comparing only DATE not the TIME.
The date property of datetime object returns just the date part

You could also use the datediff function

result = (DateDiff(DateInterval.day, date1.date, date2.date) == 1)

Open in new window