Share via

DateAdd function to only add weekdays

Anonymous
2014-09-08T16:25:26+00:00

I have a query that would like to return a date field x days after a given date field. The catch is that I only want to add weekdays and not add weekends. So for example say I have a given date of a Thursday and I want the query to return the date five days after, it would return the following Wednesday (Thursday, Friday, Monday, Tuesday, WEDNESDAY). Can an Access query do this?

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. ScottGem 68,830 Reputation points Volunteer Moderator
    2014-09-08T20:23:04+00:00

    The only way to do this is through VBA since you have to loop through the days to check each one as to whether its a weekend, holiday or weekday.

    You put the code in a global module. Then call the function like you would any built in function. 

    Sorry I missed that you want to add dates. On the same site there is a group of Workday math functions which includes an AddWorkDays function: http://access.mvps.org/access/datetime/date0012.htm

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2014-09-08T19:13:58+00:00

    First where does this code (functions) go as this does not look like SQL code? I barely know anything about modules or macro codes so if this is where you put it I will probably need some walking through it. Second it looks like these codes takes two dates and calculates the number of weekdays in between them. I however only have 1 date field and want to have a query return the date 5 weekdays from the given date.

    Was this answer helpful?

    0 comments No comments
  3. ScottGem 68,830 Reputation points Volunteer Moderator
    2014-09-08T16:46:22+00:00

    These functions can do what you want:

    http://access.mvps.org/access/datetime/date0006.htm

    Was this answer helpful?

    0 comments No comments