Results 1 to 5 of 5
  1. #1
    Bear505 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2015
    Posts
    2

    Easy one... Query that specifies doing one thing on Monday and another the rest of the days.

    I want to run an update query to update yesterdays data. so in the Criteria field I input Date()-1. Except on Monday, it needs to say Date()-3.

    I've tried something like this, but I'm not sure if I'm getting the right return.



    IIf(Weekday(1),Date()-3,Date()-1)

    I'm trying to say If, its Monday, use Date()-3, if it's Tuesday - Friday, use Date()-1

    I'm not a VBA writer, so if you could specify what to put in the Query, Criteria field, I'd really appreciate it.

    Thanks in advance.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    More like

    Date() - IIf(Weekday(Date()) = 2, 3, 1)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Not using Weekday function correctly.

    The default first day of week is Sunday, so Monday would be day 2.

    Date() - IIf(Weekday(Date())=2, 3, 1)

    Absolutely certain will never run on Sat or Sun?

    EDIT: Okay, I DID NOT copy/paste Paul's expression - great minds ...
    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.

  4. #4
    Bear505 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2015
    Posts
    2
    Ok, just so I understand... (for next time) I'm telling this that If today is Monday (Day #2) then I want to update from Friday's Data. If its Tuesday through Friday, then I want to update from yesterday's Data.

    Bear with me here..

    so if it's the Weekday's Date=2 (or Monday), subtract 3 days from today (or Friday), else just subtract 1

    Learn Something new everyday...

    Thanks guys.. Just made my Monday's a lot easier.. LOL

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 2
    Last Post: 05-29-2014, 09:30 PM
  2. Replies: 6
    Last Post: 07-17-2011, 06:42 PM
  3. Replies: 0
    Last Post: 03-29-2011, 09:37 AM
  4. Help with subforms (and the rest)
    By Franco27 in forum Reports
    Replies: 0
    Last Post: 03-14-2011, 09:43 AM
  5. Replies: 1
    Last Post: 07-27-2010, 09:47 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