Results 1 to 4 of 4
  1. #1
    Reaper is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Nov 2011
    Posts
    57

    Need to compare week of year to current week without confusing weeks in next year with this year


    I'm creating a PM scheduling database. Each of the PM's will be scheduled by a week of the year. Whenever a PM is completed it should calculate the next PM due based on the time frame, i.e., weekly, 4-week, 13-week, 26-week or 52-week. An issue arises when the next PM due rolls over to a new year. Since there is no "year" data incorporated into the week number, the weeks will start over again at 1. This will be a problem when figuring out if any PM events are due or late. For example, if the next PM is due in week 2 of 2016 and the current week is 26, comparing the week number to the current week will show this PM actually due in 2016 as past due.

    Any ideas on how to accomplish the task here?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,913
    Then include the year in the identifier, like YYYYWW.

    Or maybe instead of week number, calculate first date in week as the due value. This provides an actual date value to work with as opposed to YYYYWW, which can be saved as a number or string but is not a date value.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    I agree with June7; there's no real way you can do this kind of thing without including the year component. Aside from knowing when the next PM is due, one would think that you'd want to retain a record of each time a PM was done.

    The Date handling functions in Access VBA are really powerful and easy to utilize. A number of years ago I wrote a database using the language that VB and VBA was based on, QuickBasic 4.5, and had to do exactly what you're doing here...scheduling, in my case, follow-up home care visits that had variable frequencies. The code for doing this, and taking into account when the projected date went into the next year, if I remember correctly, about three pages of code; in Access, with DateAdd(), it would only take a single line of code!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Reaper is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Nov 2011
    Posts
    57
    Thanks for your help. Pretty much what I had concluded. I haven't had to work much with this exact problem before. Actually having the full date as June7 proposed may be more user friendly than just having the week number.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 04-20-2015, 03:22 PM
  2. Replies: 1
    Last Post: 11-01-2013, 11:53 AM
  3. Week Number of Month not Year?
    By kwooten in forum Queries
    Replies: 6
    Last Post: 05-01-2013, 06:59 AM
  4. How to display week of the year
    By wongray in forum Access
    Replies: 2
    Last Post: 12-28-2010, 04:46 AM
  5. Retrieving Week of Year in a date range
    By Korvega in forum Queries
    Replies: 2
    Last Post: 05-27-2006, 06:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums