Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / November 2006

Tip: Looking for answers? Try searching our database.

Always return next Thursday's date

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
XP - 09 Nov 2006 19:24 GMT
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!
John Spencer - 09 Nov 2006 19:45 GMT
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

> I'm usually pretty good at calculating dates, but for some reason, I'm
> blanking on this one.
[quoted text clipped - 13 lines]
> me
> a solution in VBA I would sure appreciate it. Thanks!
kingston - 09 Nov 2006 20:06 GMT
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

>I'm usually pretty good at calculating dates, but for some reason, I'm
>blanking on this one.
[quoted text clipped - 9 lines]
>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!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.