[RESOLVED] Compare Dates While Ignoring Year
This is going to sound wacky but I need to compare two dates while ignoring the year.
Dim n as Integer
n = DateDiff(DateInterval.Day, #7/1/2005#, #7/3/2006#)
n is “367” but what I really need to return is “2”
I’m trying to get the number of days before or the number of days after an anniversary date. If we were only talking about a single year it would be easy but sometimes these dates span over multiple years. Is there anyway to parse out the year and just compare the month and date? I could use a jumpstart on this one. Thanks!
Re: Compare Dates While Ignoring Year
VB Code:
Dim d1 As New Date(2005, 7, 1)
Dim d2 As New Date(2006, 7, 3)
Dim tempDate As New Date(d1.Year, d2.Month, d2.Day)
Dim dif As Integer = CInt(DateDiff(DateInterval.Day, d1, tempDate))
This should do what I think you want.
Re: Compare Dates While Ignoring Year
Works Perfectly!
Thank you!