Results 1 to 7 of 7
  1. #1
    catguy is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2010
    Location
    Minnesota
    Posts
    20

    Another removing weekends question

    I have searched through the threads many times, but just can't seem to find what I am looking for. I have a query that returns only records that are "open" greater than 3 days, however, I need to remove the weekend days from this.
    I would like to do this in an expression. This is what I currently have as an expression: Date()-[Qm15_Notifications_base]![Created on] and the criteria is > 3.
    The "Created on" field is a date format (x/xx/xxxx).
    I would think this should be somewhat easy, but am stumped.


    Any help would be greatly appreciated.

  2. #2
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    Assuming Qm15_Notifications_base is a Table name, the following should work for you. It checks to make sure [Created on] is at least 3 days in the past and that it isn't on the weekend (Sunday is the first day of the week and Saturday the 7th).
    Last edited by Rawb; 07-29-2010 at 02:50 PM. Reason: Spelling FTL :/

  3. #3
    catguy is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2010
    Location
    Minnesota
    Posts
    20
    Thanks RAWB, I really appreciate your reply... but I wasn't very clear on my needs.
    The expression you gave me does a great job of excluding [Created on] dates that would fall on a weekend day, but that's not what I need.

    Looking at the "Created_on_Age" expression Date()-[Created on], it returns the number of days between today's date and the created on date.
    If the created on date is 7/13/2010, and today's date is 7/29/2010, the returned value is "16" days. If the number of days that make up Saturdays and Sundays (non-working days, in this case "4") is removed from this equation, the results would then be "12" days.
    I guess what I am trying to achieve then, is to reduce the "Total" number of days, by the number of "weekend" days that occur between the "Date()" value and the "[Created on]" value. So the result for "Created_On_Age" (or in the case of my query "Days open") would end up being the "number of working days"
    I hope that made sense??
    Last edited by catguy; 07-30-2010 at 11:29 AM. Reason: Add clarification

  4. #4
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    I've spent all day thinking about this and have come up with the following answer: Whoever told you to do this is a sadist.

    I've been able to generate a query that *approximates* the number you want, but my exhaustion-befuddled brain keeps trying to warn me that it's not going to always be accurate.

    Maybe it can help you figure it out though!

    Also, assuming I've managed to catch up on sleep by Monday, I'll take another look at this issue (yes, it's THAT interesting).

  5. #5
    catguy is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2010
    Location
    Minnesota
    Posts
    20
    Rawb...... you are a GOD!!!!!!
    I have been crushing my brain for the last 3 weeks trying to wring every last bit of info I can to satisfy the wants/needs/desires of my sadistic boss... all to no avail (actually, he just asked if I thought it could be done, and I of course said yes.... so maybe I'm the sadist?! I've been accused of it before)

    I agree that it may not always be accurate, but I can monitor the data for awhile and see what happens.
    For now... I am happier than a pig in....... a very happy place

    Thanks so much for all the hard work... but if you find it THAT interesting.... what about holidays?! (kidding of course!!!!)

  6. #6
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    *runs through the streets naked*

    EUREKA! EUREKA!!!

    Try this:

    Code:
    SELECT Qm15_Notifications_base.[Created on], IIf(DatePart("w",[Created on])=1,0,IIf(DatePart("w",[Created on])=7,5,DatePart("w",[Created on])-2)) AS Days_Diff, DatePart("ww",Date())-DatePart("ww",[Created on]) AS Weeks_Diff, [Weeks_Diff]*5+[Days_Diff] AS Age
    FROM Qm15_Notifications_base;
    I posted the SQL code instead of giving you screenies for two reasons: 1) Your fingers will thank me and, 2) The Query as shown in the Expression Builder was too long to show

    Basically what it does though, is this: It counts each "full" week as 5 days. Then, for any "partial" weeks, it calculates Saturday and Sunday as the following Monday (so any entries from the weekend are counted as being made on the following Monday).

  7. #7
    catguy is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2010
    Location
    Minnesota
    Posts
    20
    Works like a charm!

    I hope your "run through the streets" was not quelled by any legal ramifications

    Thanks for your diligence, I'm glad it was interesting to you.
    Just one more small query to create, a little bit of code to write for automation, and this DB will be finished....... then on to the next.

    Cheers

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

Similar Threads

  1. removing security from not my own database
    By zomas in forum Security
    Replies: 1
    Last Post: 08-01-2010, 10:43 PM
  2. Weekday excluding weekends
    By jd316632 in forum Queries
    Replies: 3
    Last Post: 05-24-2010, 02:01 PM
  3. Query DateDiff calculation excluding weekends
    By Masterfinn in forum Queries
    Replies: 3
    Last Post: 04-01-2010, 09:46 AM
  4. Removing the delete prompt.
    By botts121 in forum Programming
    Replies: 4
    Last Post: 06-26-2009, 11:45 AM
  5. removing record from form
    By rsearing in forum Programming
    Replies: 7
    Last Post: 05-14-2009, 10:34 PM

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