473,765 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Autofill Date by 7 business days

7 New Member
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 2447
RuralGuy
375 Recognized Expert Contributor
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
3709
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 3-7 business days to it (excluding the weekends). I'm not worried about holidays, just weekends. Any help would be greatly appreciated! -T
1
2052
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 tables, connected them and then created different kinds of queries. (One thing I have never done is reports, because I really don't need them) I have many queries to track a particular job or aspect of it. i.e. I sent on a particular item on a...
6
1635
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. However if the number to be added is an integer this error looks awful (eg 09/07/04 plus 4 years gives 08/07/04!! DateAdd only works for integers. Anyone got any suggestions other than checking to see if the number is an integer and using DateAdd...
2
8415
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 month and put into one of the above column. If the diiferences is 0 or 30 days than value should be store in cl1Month.
10
2850
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 know a solution for this? Thanks!
9
16932
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 last visit and or called day is greater than 30 days. Now it gets confusing, Suppose the client was visited more than 30 days ago but was called only 10 days ago, I really would like to have this
9
2118
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 enters a Date in, say, FieldDate, I want FieldDateDue to be 14 days later.
10
2578
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? if they pick 7/11/08 and enter in 10 hours for a job, how can I figure out the actual date the job should end?
12
15986
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 06/15 in the first date field, I want the second field to automatically populate with 7/15. I have tried everything I can think of to no avail! I can't imagine this is a difficult thing to do........ Anyone have any ideas?
0
9568
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9398
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10156
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9832
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7375
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2805
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.