Working days - beginner (1 Viewer)

cmc2019

New member
Local time
Today, 01:53
Joined
Dec 6, 2019
Messages
1
Hi all

Hoping someone can help as I'm struggling!

I am doing a query which includes a date criteria (ie Between 01/11/2019 and 01/12/2019).

The problem is, in this date range (or any that the user will select), it needs to exclude weekends etc.

I understand there is no access function to use only working days, you have to use vba script? I have seen the scripts you can use via google searches but I cannot work out how to tailor these for my purposes OR how to apply these in access to make it work with my queries. I don't know where to start!

Any help will be massively appreciated!

thanks
 

vba_php

Forum Troll
Local time
Yesterday, 19:53
Joined
Oct 6, 2019
Messages
2,880
cmc,

I can't remember how back my FAQs and stuff were written, but look at the module code behind "_MiscFunctions" in the attached DB. The functions EDateDiff() and EDateDiffBus() might help you. In addition, I think there is also an example of what you're trying to do in my github repo here:

https://github.com/ajetrumpet102345/coding-examples
 

Attachments

  • VBA functions.zip
    222 KB · Views: 42

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 17:53
Joined
Oct 29, 2018
Messages
21,453
Hi. I don't understand, are you saying your records have weekends in them, but you don't want to see them in the query result?
 

Cronk

Registered User.
Local time
Today, 10:53
Joined
Jul 4, 2013
Messages
2,771
How do intend to select the range? Via a combo box, a text box or using query parameters?


Combos are best for providing a relatively small set of selections and forcing the user to select one. Generate the combo's value list by looping through a range of dates and excluding the weekends using the Weekday function to filter out Saturdays and Sundays.


A text box formatted as a date will provide a calendar for the user to select from. In the Before_update event you could check if a valid date was entered.


In specifying " it needs to exclude weekends etc.", what does "etc" mean?
 

Users who are viewing this thread

Top Bottom