Solved

Every third (3) week on Thursday...

Posted on 2003-12-04
6
329 Views
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?

Adawn

0
Comment
Question by:ADawn
  • 2
  • 2
  • 2
6 Comments
 
LVL 10

Expert Comment

by:ADSaunders
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
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9874032
Just do date add on your start date


ie

dateadd("d", 21, startdate)
0
 

Author Comment

by:ADawn
ID: 9874526
OK guys,

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

Thanks,
ADawn.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 10

Accepted Solution

by:
ADSaunders earned 50 total points
ID: 9874802
Hi,
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
0
 
LVL 26

Expert Comment

by:EDDYKT
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)
0
 

Author Comment

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

ADawn
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

830 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