Results 1 to 4 of 4
  1. #1
    Christopher.Rohde is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2013
    Posts
    3

    Date Problem

    I have an expression that evaluates to either a 1 or 2 based on today's date:

    Code:
    =IIf(DatePart('ww',(Date()),5,1) Mod 2>0,1,2)
    This gives me an alternating 2 week schedule period for the year starting on a thursday.



    Now, I need to return a date based on what week of the schedule period it is (1 or 2) For example, if today is Thursday of a week 1 (day1, week1) I need it to return today's date. If today is Friday of week 1, I need it to return the date of the closest Thursday (yesterday) to today and so on. If today is any day in a week 2, I need it to return the closest date of the week 1 thursday (start of the period). Example, Thursday of week 2 should return date of closest Thursday of week 1. And i need this in a single line switch or iif statement because the date returned will be used in a query as a start date to show hours worked between today and the returned date

    TIA for any assistance

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    You need to return the first Thursday of the 2-week period? Why Thursday? Why calculating between Thursday and current date?

    Review http://www.utteraccess.com/forum/Cur...-t1875718.html

    Try:

    Date()-Weekday(Date(),5)+1 - IIf(DatePart("ww",Date(),5,1) Mod 2>0,7,0)
    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
    Christopher.Rohde is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2013
    Posts
    3
    Quote Originally Posted by June7 View Post
    You need to return the first Thursday of the 2-week period? Why Thursday? Why calculating between Thursday and current date?
    The 2 week pay period starts on a thursday. I need to calculate the total overtime hours worked so far in the current period based on date()

    Good stuff

    Try:

    Date()-Weekday(Date(),5)+1 - IIf(DatePart("ww",Date(),5,1) Mod 2>0,7,0)
    I'll give that a try - thank you!

  4. #4
    Christopher.Rohde is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2013
    Posts
    3
    just had to switch the mod 2>0,7,0 to 0,7 - if there is a remainder from that calculation it is week 1 if not week 2. Thank you so much for your help!

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

Similar Threads

  1. Date problem
    By mohiahmed in forum Queries
    Replies: 8
    Last Post: 01-21-2012, 11:28 AM
  2. Date problem
    By farhanahmed in forum Access
    Replies: 1
    Last Post: 04-01-2011, 10:12 AM
  3. RST Findfirst date problem
    By ColPat in forum Programming
    Replies: 3
    Last Post: 08-09-2010, 07:28 AM
  4. Problem With Date
    By jlg759 in forum Programming
    Replies: 6
    Last Post: 07-02-2010, 12:40 PM
  5. Date Problem
    By oldteddybear in forum Queries
    Replies: 1
    Last Post: 08-30-2009, 08:52 AM

Tags for this Thread

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