Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2002
    Posts
    8

    Question Unanswered: Removing weekends from date criteria

    I'm attempting to produce a report showing production levels. The report will be run each day and will need to display only the previous day's activity. We work a normal 5-day work week, so I need to remove weekends from the query criteria.

    example: select name, count(InstallID) from install where complete_date = Date()-1;

    I thought there may be a way to produce an IF statement that will look at the weekday and if it is Monday the criteria will be 'Date()-3', Sunday will be 'Date()-2', and otherwise it will be 'Date()-1'.

    So far I have not been able to find the proper syntax for this query. Can anyone provide some information or point me in the proper direction.

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    the following should return the number of days to adjust:

    iif(weekday(YourDate, vbSunday) > 2, -1, iif(weekday(YourDate, vbSunday) 1, -2, -3))


    izy

  3. #3
    Join Date
    Dec 2002
    Posts
    8
    Thanks, this worked perfectly!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •