473,397 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

help with week days

Jim
Guys I'm rusty. Haven't messed with Access in a while.

I'm trying to determine how many workdays (or weekdays) between two dates.

I don't think their are any "canned" functions within access - or is there?

Can someone help with a simple function

count(vbweekdays, startdate,enddate), less stat holidays (LOL!)

JT

Mar 9 '08 #1
3 2391
"Jim" <ji**@pioneers.cawrote in
news:xcWAj.64813$w94.37134@pd7urf2no:
Guys I'm rusty. Haven't messed with Access in a while.

I'm trying to determine how many workdays (or weekdays) between
two dates.

I don't think their are any "canned" functions within access - or
is there?

Can someone help with a simple function

count(vbweekdays, startdate,enddate), less stat holidays (LOL!)

JT
there have been some deep discussions of this on this list over tha
last few years.

Google for the string "SetHoliday_DayOff". That's a function that
you could modify to tell you how many holidays exist. as for total
days, you use the datediff() function, not count(). You'd need to
wrap that in an user-defined function that removes 2/7ths makes
adjustments for the first and last weeks, and then deducts the
holidays.

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Mar 9 '08 #2
lots of useful info here: http://mvps.org/access/datetime/index.html
Jim wrote:
>Guys I'm rusty. Haven't messed with Access in a while.

I'm trying to determine how many workdays (or weekdays) between two dates.

I don't think their are any "canned" functions within access - or is there?

Can someone help with a simple function

count(vbweekdays, startdate,enddate), less stat holidays (LOL!)

JT
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200803/1

Mar 10 '08 #3
Here is one solution:

'--------------------------------------------------------------------------*-------------
' Procedure : CalcWorkDays
' DateTime : 5/8/2006 16:34
' Author : Dave Hargis
' Purpose : Counts the number of days between two dates excluding
Saturdays,
' : Sundays, and any days in the Holidays table
'--------------------------------------------------------------------------*-------------
'
Function CalcWorkDays(dtmStart As Date, dtmEnd As Date) As Integer
On Error GoTo CalcWorkDays_Error
CalcWorkDays = DateDiff("d", dtmStart, dtmEnd) - _
(DateDiff("ww", dtmStart, dtmEnd, 7) + _
DateDiff("ww", dtmStart, dtmEnd, 1)) + 1
CalcWorkDays = CalcWorkDays - DCount("*", "holidays", "[holdate]
between
#" _
& dtmStart & "# And #" & dtmEnd & "#")
CalcWorkDays_Exit:
On Error Resume Next
Exit Function
CalcWorkDays_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & _
") in procedure CalcWorkDays of Module modDateFunctions"
GoTo CalcWorkDays_Exit
End Function
===========================

in first Calcworkdays step
datediff 1 says how manu days between dates
datediff 2 says how many Saturdays (and subtracts them)
datediff 3 says how many Sundays (and subtracts them)
+ 1 says to count from AND to date. (Gives you an answer of 1
workday if from and to date are same)

Second Calcworkdays step then subtacts the number of holidays in that
time frame

Holiday table contains a date for every work/week day that is a
holiday (If 12/25 is a staturday then 12/24 would be in the table
since that is the workday that would be taken off in palce of 12/25)

===========================
Ron
Mar 10 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: coolcsgeek | last post by:
i took a c++ intro cs course a few years back and recently decided to major in cs after much switching back and forth between majors. it seems my school has replaced most of it's intro level cs...
3
by: CrystalDBA | last post by:
I am using SQL Server 2000. I need to query my database for all the contracts that came in during a certain time frame (user is prompted for reportingperiodid). Table - Periods Fields -...
7
by: Shuffs | last post by:
Could someone, anyone please tell me what I need to amend, to get this function to take Sunday as the first day of the week? I amended the Weekday parts to vbSunday (in my code, not the code...
2
by: Rustan | last post by:
Hi Im using GregorianCalendar to find out the current years week numbers. When the user chooses a week number in a dropdown i want to show that week in a table with the corresponding dates. For...
1
by: robinsand | last post by:
I am a new C++ programmer. I am still having trouble with certain data types and constructors, among other things. I'm not sure if I've used "std::string" properly throughout this program. I need...
6
by: aarklon | last post by:
Hi folks, I found an algorithm for calculating the day of the week here:- http://www.faqs.org/faqs/calendars/faq/part1/index.html in the section titled 2.5 what day of the week was 2 august...
7
by: derekdeben | last post by:
Hi, I have created a report that totals the number of days it took a product to ship by percentage by a date range for a specific location. My data comes from a query with the following headers: ...
8
by: ilikenwf | last post by:
I get 27 errors when I try to compile, none of which make sense to me, since the code looks good. I have my header file included, and all of my function definitions are in the class contained in the...
9
by: Joe Kovac | last post by:
Hi! Our customer wants to see his data week by week. So, how could I let him select a week the most easy way? Anyone already solved this challenge? Proposal (1): Use a calendar to select the...
3
osward
by: osward | last post by:
Hi, everyone, I had managed to make use of the date link from a simple calendar script to my query table. When I click on the date's link or Prev and Next Month link, The table first row will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.