473,769 Members | 6,337 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date Calculations

G
If one was to calculate say ten days ahead from a certain date but did not
want to include the weekdays in this count, what formula would i use in my
query column heading?
thanks.

Nov 12 '05 #1
2 3545
Don't think you can do this directly in a query... However, what you could
do, is loop through the records in the query and calculate the date, then
update a temporary table and base your report/form on the temporary table,
that now holds the newly calculated date....

Dim curDate As Date
Dim addCount As Long
Dim tmpDate As Date

curDate = Now
tmpDate = curDate
addCount = 0
Do Until addCount = 10
tmpDate = tmpDate + 1
If Format(tmpDate, "w") = 1 Or _
Format(tmpDate, "w") = 7 Then
'Saturday and Sunday
curDate = tmpDate
addCount = addCount + 1
Else
'Weekdays - not counting these,
'so do nothing
End If
Loop


"G" <sk**@optusnet. com.au> wrote in message
news:3f******** *************** @news.optusnet. com.au...
If one was to calculate say ten days ahead from a certain date but did not
want to include the weekdays in this count, what formula would i use in my
query column heading?
thanks.

Nov 12 '05 #2
"G" <sk**@optusnet. com.au> wrote in message
news:3f******** *************** @news.optusnet. com.au...
If one was to calculate say ten days ahead from a certain date but did not
want to include the weekdays in this count, what formula would i use in my
query column heading?
thanks.

This function returns the date of the week day (ie not Sat or Sun) which is
"iDaysToAdd " week days after dtStart

Function AddWeekDays(ByV al dtStart As Date, ByVal iDaysToAdd As Integer) As
Date
Dim dtTemp As Date

dtTemp = DateAdd("ww", iDaysToAdd \ 5, dtStart) ' add whole weeks first
dtTemp = DateAdd("d", iDaysToAdd Mod 5, dtTemp) 'add on part-week days
If Weekday(dtTemp, vbMonday) > 5 Then dtTemp = DateAdd("d", 2, dtTemp)
AddWeekDays = dtTemp
End Function

Tested code.
Nov 12 '05 #3

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

Similar topics

1
2078
by: mene | last post by:
I have a field that contains date information, and sometimes time information as well. I would like to be able to take that date and do a calculation on it. Here are some examples of what is in the field: 01/12/2003 5:04:00 PM 24/11/2003 19/05/2003 6:30:00 AM How can I take that date, then do a calculation like minus 5 days from the date. I understand that I am to use the GETDATE() function, but below is
11
4675
by: lduperval | last post by:
Hi, I`m trying to do date calculations in three types of time zones: local, GMT and specified. The issue I am facing is that I need to be able to specify a date in the proper time zone, and I`m having a heck of a time doing so. I have created a form where I use drop downs do specify year, month, date, hour, minute and seconds. When the form is loaded, the dropdowns have to display the proper values for the current time zone type. This
2
7335
by: Joe Jax | last post by:
I have some date calculations that add a time span to a date. The problem is, when I add a time span that is a whole number of days to a date, the result can be +/- 1 hour due to daylight savings. Is there anyway to disable this?
2
425
by: Mark Lees | last post by:
I need some help setting up some date caluclations. Fields Include: A. DOB "date of birth" B. IFSPOrginal "Date IFSP is entered" C. IFSPRedo "Date 12 months into the future from IFSPOrginal" D. 2yrTransistion "Date 2yrs into the futre from DOB" I'm having difficulty creating the expressions for the (C)IFSPRedo and
2
404
by: Roffee | last post by:
Hi. I'm a bit confused about date functions in Access. I need the program to calculate a new date that lays 15 days ahead of a given date in a table. I studied the datediff function, but as I see it, it only returns a number of days (or other time period) between two dates. I need a future date as output. Hints anyone?
2
6516
by: Julie Wardlow | last post by:
Help! I am calculating a future date using the DateAdd function in a query (the calculation also involves an IIf statement), and have managed to get this formula to produce the required result. I then want to search through the records and select those with dates (as caluclated above) within a user defined range, and so I am using a parameter query. However, this query returns dates outside of the range and appears to have particular...
1
6135
by: Wayne | last post by:
Hi all I'm trying to calculate the number of days (or workdays) between 2 given dates that do not include weekend days or public holidays (public holidays are user defined from a dbase, have a start date & an end date & may span a weekend) If a start date (workday) & an end date (workday) are on the same day then the number of workdays will equal zero Some eg's.
8
2113
by: Charlie Brookhart | last post by:
I am creating a program that involves having to find the difference between two dates and converting it to a number to be used for calculations. The problem is that the way it is setup, VB is not doing anything with the dates that I have selected. I hope that someone here can help me figure out why it is not working what I have to do to make it work. This the code I have for the date calculations. txtNumberOfDays.text =...
11
3920
by: arggg | last post by:
I have a table with with Last_Modified field as VARCHAR(55) which stores dates in the format of 2/15/08 1:34 PM. What I need to do is query the database and select ALL rows that have the Last_Modified field >= 6 days from the current date/time. It appears I will need to convert the dates so I can use the mysql calculations but I'm unsure where to begin on this.
1
2295
by: MadSma | last post by:
hi as i am a newbie to access i need some help for some basic functionality i need to be able to calculate a date after 6 or 12 months based on a staring date the user inputs on my form as well as an intervaldate of the users choices ok what do i have in a form called duration i have 1. a list box that holds 2 values(6months and 12 months) 2. a dateField called 3. a date field called
0
9589
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
10222
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
10050
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9999
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9866
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...
1
7413
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
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3570
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.