473,394 Members | 2,160 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,394 software developers and data experts.

Autofill Date by 7 business days

i need help again on calculating business days excluding holidays
i have a field called assign date and i need to calculate 7 business days excluding holidays ( already have a table for holiday) from that date. i have read some forums on getting total business day but not the other way around
Aug 12 '08 #1
1 2415
RuralGuy
375 Expert 256MB
Here's a function you can use:
Expand|Select|Wrap|Line Numbers
  1. Public Function PlusWorkdays(dteStart As Date, intNumDays As Long) As Date
  2.  
  3. PlusWorkdays = dteStart
  4. Do While intNumDays > 0
  5.      PlusWorkdays = DateAdd("d", 1, PlusWorkdays)
  6. '     If Weekday(PlusWorkdays, vbMonday) <= 5 Then
  7. '-- If you have a Holiday Table use the next IF instead!
  8.      If Weekday(PlusWorkdays, vbMonday) <= 5 And _
  9.       IsNull(DLookup("[HoliDate]", "tblHolidays", _
  10.       "[HoliDate] = " & Format(PlusWorkdays, "\#mm\/dd\/yyyy\#;;;\N\u\l\l"))) Then
  11.       '-- The above Format of PlusWorkdays works with US or UK dates!
  12.           intNumDays = intNumDays - 1
  13.      End If
  14. Loop
  15.  
  16. End Function
Aug 13 '08 #2

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

Similar topics

4
by: tom feldman | last post by:
I am hoping somebody can help me solve this problem... I need to write .asp code for a web page that adds 3-7 'business' days to a given date. I can retrieve the date just fine, but, how do I add...
1
by: EnriqueM | last post by:
One question: I created an access database that has been extremely useful in my work. I dont' even know at what level of knowledge I am at. I read a lot about how to create a database, created many...
6
by: shurstgbr | last post by:
I want to add a number (for example 7.5) to a date. I've been using 365.2425*7.5 and then adding this to the date. This gives an answer that is close and in most cases the error is unnoticeable....
2
by: Niyazi | last post by:
Hi everyone, I have a sql table that has 5 column as: cl1Month - cl1_3Month - cl3_6Month - cl6_12Month - clMoreThan12Month Now I have to date and I have to find the differences and check as...
10
by: sandraz444 | last post by:
I have an expression in the query under my form to autofill the date under a certain condition but it wont write to the underlying table?? The date shows in the form but not the table. Does anyone...
9
by: ice | last post by:
Hello, I have a couple of tables. The client tables and the contacted tables. I am not sure how to start on this, what I need is a way to query all my clients then show any client that the...
9
by: nyakki | last post by:
Hello, Very new to Access. I searched this forum but didn't even know where to start. I come from a programming background so I'm not afraid of logic :) What I want to do: When someone...
10
by: Scott | last post by:
I have an application that allows the user to pick a start date, then the enter in a number of hours to do a job, then a stop date fills out a textbox. Is there a way to find out the stop date? ...
12
by: klbrownie | last post by:
Hello, I am trying to get a date field to autofill based on the date of another date field. I want the autofilled date to be 30 days after the other date. For example, if the user has entered...
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:
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.