473,774 Members | 2,275 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1995
On Jan 22, 7:37*am, Paul <burnsp...@hotm ail.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********@yah oo.comwrote in message
news:5a******** *************** ***********@i12 g2000prf.google groups.com...
On Jan 22, 7:37 am, Paul <burnsp...@hotm ail.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...@hotm ail.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
5129
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 for each record, each row accounts for a different type of outcome I'm having trouble with MySQL date comparison. I'm looking for some kind of query that will compare the all date column and only give me the latest date. Then once I have it, ...
1
4824
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? The reason I ask is that TimeA and TimeB are significant down to seconds. My *assumption* is that with a large amount of data scatter very few records will contain duplicate date/time points. And that under these circumstances, indexing will be of...
4
6294
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 field names). Essentially, I would like to sort the DATE FIELDS for each record in the table by the order of the DATES in those DATE FIELDS. For example: record ID= 354
5
1979
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 harder to summarise the data by day in my reports... I think the dates are stored in front of the decimal and the time is stored after the decimal.. so it seems to me if i was storing integers in my fields instead of real numbers I'd have the...
1
353
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 tried, but it only puts the date part of it into the field. any ideas ?? thanks
8
6415
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 the combo box. The fields I am working with are date fields that are formated as Short Date. I have written an IIF statement and placed it within the Criteria section of the Date field that I am trying to filter by. The current IIF statement works...
10
5821
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 date format in the table design, such as: mm/dd/yyyy? What I've done for years is to store the date format in date fields, then on the forms, based on their region, I would set the date formats on form_load
3
5994
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 have never actually learnt VB so my request is that you bear this in mind if you plan on replying to this post. My request for help is as follows: I have an MS Access database in which one of the tables within it contains two date fields called...
22
3602
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 in one of the fields that is a Date field I cannot get the update to work. ie) this line ". = #" & Nz(rst.Fields(9).Value, "") & "#," & _ Could someone assist me with the correct syntax to use. I also need to consider that the field may be...
8
2781
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. The problem is that when I use that criteria for all four fields I am not getting the expected results. I am trying to find out from this query is the date in date field one is older than 180, same thing for the other three date fields. For...
0
9621
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
9454
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
10264
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
10106
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
10039
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
6717
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();...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4012
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
3
2852
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.