473,386 Members | 1,705 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,386 software developers and data experts.

How to calculate number of workdays in access2013 query

In the attached image I was trying to calculate number of working days(throughput) b/w item received_date and item_released date by using datadiff with "w" interval . but if I use "w" interval it brings value zero .but if I use "d" interval then it brings result with inclusive of Saturdays and Sundays.i don't need that.

so can you help me to calculate the number of working days exclusive of Saturdays and sundays.


Attached Images
File Type: jpg w interval.jpg (44.8 KB, 7900 views)
File Type: jpg d interval.jpg (45.5 KB, 7770 views)
Aug 7 '14 #1
6 15757
twinnyfo
3,653 Expert Mod 2GB
ESAKKI,

It might be more feasible to write a small VBA function that you can call, sending the start and stop dates. The function would start at the start date, and add a day. If that date is not a Saturday or Sunday, then have a counter that increments by one. Once the function increments the date to the end date, it exits, returning the value of the counter.

Very rough concept here:

Expand|Select|Wrap|Line Numbers
  1. Public Function WorkDays(StartDate As Date, StopDate As Date) As Integer
  2.     Dim intCounter As Integer
  3.     Dim dtHold As Date
  4.     intCounter = 0
  5.     dtHold = StartDate
  6.     Do While Not dtHold > StopDate
  7.         If Weekday(dtHold, vbSunday) > 1 And _
  8.             Weekday(dtHold, vbSunday) < 7 Then
  9.                 intCounter = intCounter + 1
  10.         End If
  11.         dtHold = DateAdd("d", 1, dtHold)
  12.     Loop
  13.     WorkDays = intCounter
  14. End Function
But, thinking about it, it just might work as is....

As an example,

Expand|Select|Wrap|Line Numbers
  1. WorkDays (#6/1/2014#, #6/7/2014#)
Returns 5.
Aug 7 '14 #2
Seth Schrock
2,965 Expert 2GB
Check out the following link: DateDiff for Business Days. This particular solution excludes holidays, Saturdays and Sundays. If you don't care about holidays, then you could leave that part out and just look at how it excludes the weekend.
Aug 7 '14 #3
zmbd
5,501 Expert Mod 4TB
In addition to the information in that thread there is also our insight's article for those with a prefernce for SQL:
How To Calculate Business days, A Pure SQL approach
Aug 7 '14 #4
Hi Twinnyfo ,

thanks for the vba coding . I am not very much familiar with vba coding .but I understood the concept of your coding . my doubt is ?
Is this coding for Microsoft access2013 or MS excel ? because I don't know how to implement this code in MS Access2013 . where do need to implement these whether in MS access form or queries ??.
In my case (refer screenshot) what need is(exact wordings) throughput = RECEIVED_DATE - ITEM_RLEASED DATE . Do I need to change any wordings in your coding according to my convenience . Also where I need to paste these coding in MS access query.
Aug 8 '14 #5
zmbd
5,501 Expert Mod 4TB
ESAKKI109
I'll be forwarding a copy of my basic tutorial boiler plate.
You need to work thru the examples and take a look at the other reference links.
As much as we like to help, there are certain fundamentals that you must simply have mastery of, such as the Access UI, in order for you to get the most out of our help.

>>edit>> Sent, Please Check your Bytes.com inbox (^_^)
Aug 9 '14 #6
twinnyfo
3,653 Expert Mod 2GB
Esakki,

You can use the VBA I posted just about anywhere within your project, as it is a public function. It just depends on how and when you want to get the number of workdays. You can also use the Function as part of the query you have displayed. It can be one of your output fields.
Aug 12 '14 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Terry | last post by:
From the packet data returned from a query, where in the packet data are the bytes signifying the number of rows returned? Thanks, Terry
2
by: Rimdur | last post by:
I am trying to get a difference between two dates calculated in a query. I have Sales_Date as the first one, and Date() as the second one. How would I put the difference of these two days into a...
3
by: John Ortt | last post by:
> I have a table of dates in ascending order but with varying intervals. I > would like to create a query to pull out the date (in field 1) and then pull > the date from the subsequent record...
6
by: carl.barrett | last post by:
Hi, I have a continuous form based on a query ( I will also be creating a report based on the same query). There are 2 fields: Date Obtained and Date Of Expiry I want a further 3 columns...
5
by: Beemer Biker | last post by:
I cant seem to get that date into any DateTime to make my calculation directly by subtracting "01-01-0000" from "now". After reading this:...
4
by: shilpareddy2787 | last post by:
Hello, I have some total values, I want to calculate percenatge of these Total Values. I want to divide the total with No. Of working Days Excluding Saturdays and Sundays in a given period. ...
6
by: sarfraznawaz | last post by:
Hi, I am Web Designer. I am new to this coding related job. Can anyone help me how to sort this out. How to calculate number of words with given price? Thanks. Sarfraz
7
by: Jerx | last post by:
Hello all, Iam a newby to Access but for learning purposes iam building an Access Database in Access 2007 (a CMDB). In the database i got so called configurations. In a configurations there are...
0
by: ravikumarmeduri | last post by:
Dear All, Require your support to write a query in sql server. I have a table (report) with Country, Status, Open Date, Close date. Values in country is - India, USA, UK, etc.., status is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.