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

Date Fields

Thanks to all the advice I have received but I seriously need more
help (in more ways than one).

The crux of the problem is that I need to insert a date into
ClockStarts field and have access display another date into TargetDate
field (plus 20 days but excluding Sat/Sun and holidays)

If someone could give me the code to do this I would be forever in
your debt. Thanks
Jan 22 '08 #1
3 1949
On Jan 22, 7:37*am, Paul <burnsp...@hotmail.co.ukwrote:
Thanks to all the advice I have received but I seriously need more
help (in more ways than one).

The crux of the problem is that I need to insert a date into
ClockStarts field and have access display another date into TargetDate
field (plus 20 days but excluding Sat/Sun and holidays)

If someone could give me the code to do this I would be forever in
your debt. Thanks
The sat/sun part is not too difficult but you have to define what a
holiday is to accomplish the rest.
Jan 22 '08 #2

<fr********@yahoo.comwrote in message
news:5a**********************************@i12g2000 prf.googlegroups.com...
On Jan 22, 7:37 am, Paul <burnsp...@hotmail.co.ukwrote:
Thanks to all the advice I have received but I seriously need more
help (in more ways than one).

The crux of the problem is that I need to insert a date into
ClockStarts field and have access display another date into TargetDate
field (plus 20 days but excluding Sat/Sun and holidays)

If someone could give me the code to do this I would be forever in
your debt. Thanks
The sat/sun part is not too difficult but you have to define what a
holiday is to accomplish the rest.

Normal practice is to maintain a table of holidays and look them up.

Jan 23 '08 #3
On Jan 22, 7:37*am, Paul <burnsp...@hotmail.co.ukwrote:
Thanks to all the advice I have received but I seriously need more
help (in more ways than one).

The crux of the problem is that I need to insert a date into
ClockStarts field and have access display another date into TargetDate
field (plus 20 days but excluding Sat/Sun and holidays)

If someone could give me the code to do this I would be forever in
your debt. Thanks
Try this it works for me. I cannot include weekends or holidays to
calculate days
late on an account. So I created the following function called
"DayOff"

Private Sub CBStart_Click()
Dim Count1 As Integer
Dim StartDate As Date, EndDate As Date
StartDate = "11/20/2007" ' You would provide the
start date
EndDate = StartDate
While Count1 < 20 ' 20 = Number of days to add
EndDate = DateAdd("d", 1, EndDate)
If DayOff(EndDate) = False Then
Count1 = Count1 + 1
End If
Wend
EndDate = Format(EndDate, "mm/dd/yyyy")
MsgBox str(EndDate)
End Sub

Function DayOff(Indate As Date) As Boolean
' This function converts any day to the Long Day format which contains
The Name of the day of the week
' If the Name of the day of the week is either Friday or Saturday then
the function is true
' I've given some examples of some holidays but you must add your own
if they are differend
Dim hstring As String
hstring = FormatDateTime(Indate, vbLongDate)
If InStr(hstring, "Saturday") Then DayOff = True
If InStr(hstring, "Sunday") Then DayOff = True
If Month(Indate) = 7 And Day(Indate) = 4 Then Dayoff - True '
July 4th
If Month(Indate) = 12 And (Day(Indate) = 24 Or Day(Indate) = 25 Or
Day(Indate) = 31) Then DayOff = True ' Christmas Eve Christmas
Day NewYears Eve
If Month(Indate) = 1 And Day(Indate) = 1 Then DayOff = True '
NewYears Day
If Month(Indate) = 9 And InStr(hstring, "Monday") And Day(Indate) < 8
Then DayOff = True ' LaborDay
' Laborday is always the first Monday of September. if the month is
9 and the day is Monday and the Day of the Month is less than 8 then
it is laborday
If Month(Indate) = 11 And InStr(hstring, "Thursday") And (Day(Indate)
21 And Day(Indate) < 29) Then DayOff = True ' Thanksgiving
' Thanksgiving is always the 4th Thursday of November. So if month =
11 and day = Thursday and day of month is greater than 21 and less
than 29 it is Thanksgiving.
If Month(Indate) = 11 And InStr(hstring, "Friday") And (Day(Indate) >
22 And Day(Indate) < 30) Then DayOff = True ' Friday after
Thanksgiving
End Function

Jan 29 '08 #4

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

Similar topics

4
by: Gleep | last post by:
Hey Guys, I've got a table called Outcomes. With 3 columns and 15 rows 1st col 2nd col 3rdcol outcome date price There are 15 rows...
1
by: Thomas Bartkus | last post by:
If we have a date/time field and are doing frequent queries WHERE {date/time field} BETWEEN TimeA AND TimeB Does it make sense, query speed wise, to create an index on the date/time field? ...
4
by: Joe User | last post by:
Hi all....I have a feeling this is going to be one of those twisted query questions, but here it goes anyways.... I want to generate a report that shows the chronology of events (represented by...
5
by: Helen R Martin | last post by:
I'm struggling once more with the dates in one of my Access projects.. I'd like the date/time fields to be just date fields.. its just confusing the folks using the database, and its making it...
1
by: brino | last post by:
hi all ! i have 2 fields in a form - a Date field & a Time field. these 2 fields have to be combined into the one field which has date & time. i know there must be some code to do this. i have...
8
by: Ragbrai | last post by:
Howdy All, I have a query that is used for filtering results to be used in a combo box. The query needs to test fields from both a table and then unbound text boxes on the form that also contains...
10
by: ARC | last post by:
Hello all, General question for back-end database that has numerous date fields where the database will be used in regions that put the month first, and regions that do not. Should I save a...
3
by: Harlequin | last post by:
I must start this posing by making the point that I am NOT a VB programmer and I'm something of a Newbie to MS Access. I can program in a number of languages (Java, Javascript, PERL,PHP and TCL) but...
22
by: tonialbrown | last post by:
I have an Sql update statement that I am using that updates the data from a record chosen by the user from a list box lstDelFrom. This is working for all the text fields & updates fine. Once I add...
8
by: Dr Al | last post by:
I have a table with four date fields, some of which may not be filled in based on our data entry needs. I have a criteria set as <date()-180 which is supposed to pull dates older than 180 days ago....
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?
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
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
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...
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...
0
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,...
0
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...

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.