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

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 3525
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.a u...
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.a u...
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(ByVal 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
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...
11
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...
2
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....
2
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...
2
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...
2
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....
1
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...
8
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...
11
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...
1
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...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.