Always return next Thursday's date

G

Guest

I'm usually pretty good at calculating dates, but for some reason, I'm
blanking on this one.

I need a function such that it always returns next Thursday's date, based on
today.

So, if today is Friday, I get next Thursday's date; if today is Wednesday, I
get next Thursday's date (tomorrow); if today is Thursday, then I get, you
guessed it, NEXT Thursday (a week from today)...etc.

I like using separate functions, so a function that can be called and return
my date would be ideal, but the code is the main thing. IF anyone can post me
a solution in VBA I would sure appreciate it. Thanks!
 
J

John Spencer

Really quick and dirty function

Public Function NextThursday(DateIn)
'Handles nulls, invalid dates, and strings or date inputs.

Dim rtnVal As Date

If IsDate(DateIn) = False Then
NextThursday = DateIn
Else
rtnVal = DateAdd("d", 5 - Weekday(DateIn), DateIn)
If rtnVal <= DateValue(DateIn) Then rtnVal = DateAdd("d", 7, rtnVal)
NextThursday = rtnVal
End If

End Function
 
K

kingston via AccessMonster.com

Assuming your system is set so that weeks start on sunday (weekday 1):

If Weekday(Date()) < 5 then
NextThursday = Date() + (5-Weekday(Date()))
Else
NextThursday = Date() + (12-Weekday(Date())
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top