473,386 Members | 1,621 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.

weekdays calculation

Could someone please help.... ? below are my code on how to create indate and outdate.
Expand|Select|Wrap|Line Numbers
  1.                           If Not IsNull(rst2.Fields("Days_Required")) Then
  2.                             days = rst2.Fields("Days_Required")
  3.  
  4.                         End If
  5.  
  6.                        enddate = rst2.Fields("FinalDate")
  7.                        If days = 0 Then
  8.                             startdate = enddate
  9.                         Else
  10.                            startdate = DateAdd("w", -days, enddate)
  11.  
  12.                         End If
the calculation for startdate and enddate are correct according to days required. the problem is that it calculates weekend as well. for example: enddate is 1/27/09, it required to works for 8 days, then the start date should be enddate - 8 days (exclude weekend sat and sun) = 1/16/09, but the code is giving me 1/20/09 as startdate.
Can someone help me?? I thought "w" is for weekdays only
Feb 5 '09 #1
3 1493
ChipR
1,287 Expert 1GB
Quoted from another thread:
WEEKDAY is just the numerical representation of each day (Sunday=1, Monday=2, ..., Saturday=7), but includes ALL days of the week (doesn't exclude weekends). I believe that you want WORKDAY.

Unfortunately, Workday is not a function that exists in Access. I think there was a thread not too long ago where someone wrote it though.
Feb 5 '09 #2
ChipR
1,287 Expert 1GB
http://bytes.com/topic/access/answer...y-calculations

Post #3 by NeoPa
Feb 5 '09 #3
ADezii
8,834 Expert 8TB
Here is some code I wrote a short time ago, that will allow you to calculate workdays minus Weekends and Holidays. It may/may not be helpful to you. Refer specifically to Post #9.
http://bytes.com/topic/access/answer...ding-holidays-
Feb 8 '09 #4

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

Similar topics

2
by: Tiernan | last post by:
Hi all I'm looking for a way to find the number of weekdays between 2 dates In my form I have three fields for a begin date (dd)(mm)(yyyy) and three for the end date (dd)(mm)(yyyy) Now these...
4
by: John | last post by:
hey all..... alright, I am frusterated to the point of throwing my machine out the window (this board went down, trying to find stuff on google, this has been a nightmare) so I hope you guys can...
2
by: JP SIngh | last post by:
Hi All I need to calculate the number of working days between the two dates entered on an ASP page. I am not that great a coder in ASP and was wondering if someone can help. Basically the...
5
by: SimonC | last post by:
Help needed for a Javascript beginner. As above in the subject... i need a javascript to run this, but not in the form of a web-page. I want to calculate it between 2 fields in a database that...
8
by: James Fortune | last post by:
I'm doing some computations in order to do capacity planning. Instead of using some function from an Access book to do the weekday calculation, I decided to come up with an alternate method since...
2
by: rajeevs | last post by:
Hi I been away for sometime. Pls help me with my new problem i need to do a leave calculation using a text box. I have a start date (date format) and number of days(number). The calculation i...
4
by: MLH | last post by:
I'm thinking of an integer field in which I could write values up to 1+2+4+8+16+32+64 and to use these values later. Each of the individual values would represent a weekday from Sunday to Saturday....
2
by: Mike | last post by:
Is there a way to calculate the total number of weekdays when provided a date? Example: If I have a start date of 7/11/2008 and I want to go out 10 days, I want to get this: 6 weekdays 4...
1
by: bharathreddy | last post by:
This article will explain how we can get the count of weekdays in between two dates. This will be usefull if we want to count the number of working days between two dates. Example: -------------...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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,...
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...

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.