Every third (3) week on Thursday...

Posted on 2003-12-04
Last Modified: 2011-09-20
Hello All,

I have no idea how to begin to have my application retrieve records based on the following:

In the options section of my application the app user can choose to have a [reminder] set to notify them (say) "Every 3 weeks on a Thursday.' I have the following fields created.

Start Date, Number of Weeks, chkSun, chkMon, chkTue, chkWed... all seven days.

How can I recall [as a reminder] this data [Every 3 weeks on a Thursday] ?

Please remember that number of weeks and days will change per the app user.

Please, any ideas?


Question by:ADawn
  • 2
  • 2
  • 2
LVL 10

Expert Comment

ID: 9873852
Firstly, There's no point in pre-calculating the reminder dates. How far forward would you calculate, and what if the user changes his/her options?

I would have another field 'Next Reminder', and would calculate it every time the reminder triggered, and every time the options were changed. then the logic for triggering a reminder is simply ' is it today? ' or :
if Next Reminder = date() then .....

Then I would trim the day variables to a single integer where 1 = Sunday and 7 = Saturday (say Wday).

Then the calculation becomes:

Next Reminder = date() + (Number of weeks * 7)
Today = DatePart("w", date())
if Wday - Today < 0 then     Next Reminder = Next Reminder + 7
Next Reminder = Next Reminder + Wday - Today

.. Any Use??
.. Alan
LVL 26

Expert Comment

ID: 9874032
Just do date add on your start date


dateadd("d", 21, startdate)

Author Comment

ID: 9874526
OK guys,

I'll need a little time to digest this stuff. I'm get back with you soon - I hope :).

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

LVL 10

Accepted Solution

ADSaunders earned 50 total points
ID: 9874802
My previous comment was written 'on the fly'. Just to prove it worked, icopied the pseudocode into a VB project, corrected syntax errors, and it ran first time:

Dim NextReminder As Date
Dim WDay As Integer ' Day of week 1=Sun, 2=Mon etc ... 7 = Sat
Dim Today As Integer
Dim NumberOfWeeks As Integer

NumberOfWeeks = 3 ' Required reminder 3 Weeks
WDay = 2                 '     "              "       on Monday
NextReminder = Date + (NumberOfWeeks * 7) 'Calculate date n weeks ahead (current day)
Today = DatePart("w", Date)  ' find todays day number
If WDay - Today < 0 Then NextReminder = NextReminder + 7 ' * See Note
NextReminder = NextReminder + WDay - Today ' Add the difference between required day and today
MsgBox NextReminder

* Note This line is only required if reminder is wanted '3 weeks NEXT Monday' In My tests I checked today (4/12/2003 if you're English, or 12/4/2003 if you're American):

With this line NextReminder was 29/12/03 (12/29/03)
Without this line NextReminder was 22/12/03 (12/22/03)

.. Alan
LVL 26

Expert Comment

ID: 9874934
How about this

Dim WDay As Integer ' Day of week 1=Sun, 2=Mon etc ... 7 = Sat
Dim NumberOfWeeks As Integer

NumberOfWeeks = 3 ' Required reminder 3 Weeks
WDay = 2                 '     "              "       on Monday
MsgBox DateAdd("d", NumberOfWeeks * 7 + WDay - Weekday(Now) + 7, Date)

Author Comment

ID: 9893562
Lots of stuff to work with. Thanks to all!


Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now