473,770 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calculate a job End Date

Hi Access Building Friends,

I am building a database for a manufacturer who needs to know the projected
End_Date of each job.

I know the Start_Date and the total days required to do the job.

I need to calculate the End_Date after taking into account Weekends and
Holidays.

I have a table which lists the dates of each holiday for several years to
come.

I tried using a code I found called, "Public Function WorkingDays" which
calculates the number of working days and holidays between two dates, but it
doesn't push the End_Date ahead to fulfill the working days needed.

I appreciate any help you can offer.

Thanks,
Connie

--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200809/1

Sep 9 '08 #1
11 2518
okay, try this function, as

Public Function calcDate(ByVal dat As Date, ByVal intAdd As Integer) As Date

Dim i As Integer, bump As Boolean, str As String

dat = CDate(Fix(dat))
i = 1

For i = 1 To intAdd
dat = dat + 1
Do
bump = False
If DCount(1, "tbl00Holidays" , "hDate = #" & dat & "#") 0 Then
dat = dat + 1
bump = True
End If

str = Format(dat, "ddd")
If str = "Sat" Then
dat = dat + 2
bump = True
ElseIf str = "sun" Then
dat = dat + 1
bump = True
End If
Loop Until bump = False
Next

calcDate = dat

End Function

the arguments are: a beginning date, and a number of days. the function
returns the calculated end date. the function uses a table that holds
holidays and any other dates (outside of weekends) that should not be
counted. the table is tbl00Holidays, and the date field is hDate - but of
course you can substitute the appropriate table and field names from your
holidays table.

hth
"Connie via AccessMonster.c om" <u35472@uwewrot e in message
news:89eac425ac 847@uwe...
Hi Access Building Friends,

I am building a database for a manufacturer who needs to know the
projected
End_Date of each job.

I know the Start_Date and the total days required to do the job.

I need to calculate the End_Date after taking into account Weekends and
Holidays.

I have a table which lists the dates of each holiday for several years to
come.

I tried using a code I found called, "Public Function WorkingDays" which
calculates the number of working days and holidays between two dates, but
it
doesn't push the End_Date ahead to fulfill the working days needed.

I appreciate any help you can offer.

Thanks,
Connie

--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200809/1

Sep 9 '08 #2
"Connie via AccessMonster.c om" <u35472@uwewrot e in message
news:89eac425ac 847@uwe...
Hi Access Building Friends,

I am building a database for a manufacturer who needs to know the
projected
End_Date of each job.

I know the Start_Date and the total days required to do the job.

I need to calculate the End_Date after taking into account Weekends and
Holidays.

I have a table which lists the dates of each holiday for several years to
come.

I tried using a code I found called, "Public Function WorkingDays" which
calculates the number of working days and holidays between two dates, but
it
doesn't push the End_Date ahead to fulfill the working days needed.

I appreciate any help you can offer.

Thanks,
Connie

--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200809/1

You might try something like the function below. It's untested "air" code
but it might work ;) I've made the assumption that you have a table named
tblHolidays with a date field named Holiday that contains all of your
holidays. The function takes two parameters (BegDate and WorkDays) and will
return the EndDate.
Fred Zuckerman

Public Function FindEndDate (BegDate As Date, WorkDays As Integer) As Date
Dim t As Integer 'Total Days
Dim w As Integer 'Work Days
t = 0
w = 0
Do While True
t = t + 1
' Check To See If Date Is Sat, Sun, or Holiday
If Weekday(BegDate + t) >= 2 And _
Weekday(BegDate + t) <= 6 And _
IsNull(Dlookup( "Holiday","tblH olidays","Holid ay=#" & (BegDate + t)
& "#")) Then
w = w + 1
Endif

If w=WorkDays Then
Exit Loop
Endif
Loop
FindEndDate = BegDate + t
End Function

Sep 9 '08 #3
Hi Tina,

Thank you for your speedy reply.

I am excited to try your code.

Connie :)

tina wrote:
>okay, try this function, as

Public Function calcDate(ByVal dat As Date, ByVal intAdd As Integer) As Date

Dim i As Integer, bump As Boolean, str As String

dat = CDate(Fix(dat))
i = 1

For i = 1 To intAdd
dat = dat + 1
Do
bump = False
If DCount(1, "tbl00Holidays" , "hDate = #" & dat & "#") 0 Then
dat = dat + 1
bump = True
End If

str = Format(dat, "ddd")
If str = "Sat" Then
dat = dat + 2
bump = True
ElseIf str = "sun" Then
dat = dat + 1
bump = True
End If
Loop Until bump = False
Next

calcDate = dat

End Function

the arguments are: a beginning date, and a number of days. the function
returns the calculated end date. the function uses a table that holds
holidays and any other dates (outside of weekends) that should not be
counted. the table is tbl00Holidays, and the date field is hDate - but of
course you can substitute the appropriate table and field names from your
holidays table.

hth
>Hi Access Building Friends,
[quoted text clipped - 17 lines]
>Thanks,
Connie
--
Message posted via http://www.accessmonster.com

Sep 9 '08 #4
Hi Fred,

Thank you for reading my post and giving my your "air" code.

I am hopeful.

Connie :)

Fred Zuckerman wrote:
>Hi Access Building Friends,
[quoted text clipped - 19 lines]
>Thanks,
Connie

You might try something like the function below. It's untested "air" code
but it might work ;) I've made the assumption that you have a table named
tblHolidays with a date field named Holiday that contains all of your
holidays. The function takes two parameters (BegDate and WorkDays) and will
return the EndDate.
Fred Zuckerman

Public Function FindEndDate (BegDate As Date, WorkDays As Integer) As Date
Dim t As Integer 'Total Days
Dim w As Integer 'Work Days
t = 0
w = 0
Do While True
t = t + 1
' Check To See If Date Is Sat, Sun, or Holiday
If Weekday(BegDate + t) >= 2 And _
Weekday(BegDate + t) <= 6 And _
IsNull(Dlookup( "Holiday","tblH olidays","Holid ay=#" & (BegDate + t)
& "#")) Then
w = w + 1
Endif

If w=WorkDays Then
Exit Loop
Endif
Loop
FindEndDate = BegDate + t
End Function
--
Message posted via http://www.accessmonster.com

Sep 9 '08 #5
Hi Tina,

This code works great! Thank you so much. :)
Could you tell me how to make it include the Start_Time and an End_Time?
I'm thinking it has to do with the "As Date" setting, but don't know how to
make it, "As Date/Time"

Thanks again,

Connie

tina wrote:
>okay, try this function, as

Public Function calcDate(ByVal dat As Date, ByVal intAdd As Integer) As Date

Dim i As Integer, bump As Boolean, str As String

dat = CDate(Fix(dat))
i = 1

For i = 1 To intAdd
dat = dat + 1
Do
bump = False
If DCount(1, "tbl00Holidays" , "hDate = #" & dat & "#") 0 Then
dat = dat + 1
bump = True
End If

str = Format(dat, "ddd")
If str = "Sat" Then
dat = dat + 2
bump = True
ElseIf str = "sun" Then
dat = dat + 1
bump = True
End If
Loop Until bump = False
Next

calcDate = dat

End Function

the arguments are: a beginning date, and a number of days. the function
returns the calculated end date. the function uses a table that holds
holidays and any other dates (outside of weekends) that should not be
counted. the table is tbl00Holidays, and the date field is hDate - but of
course you can substitute the appropriate table and field names from your
holidays table.

hth
>Hi Access Building Friends,
[quoted text clipped - 17 lines]
>Thanks,
Connie
--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200809/1

Sep 9 '08 #6
comments inline.

"Connie via AccessMonster.c om" <u35472@uwewrot e in message
news:89f118989a fbc@uwe...
Hi Tina,

This code works great! Thank you so much. :)
you're welcome, glad it works for you. :)
Could you tell me how to make it include the Start_Time and an End_Time?
I'm thinking it has to do with the "As Date" setting, but don't know how
to
make it, "As Date/Time"
well, in Access, a date value stored as Date/Time data type *always* has a
time - a default of midnight, if nothing else. so the return value of the
function does include a time, but it is the default. in fact, i specifically
included code in this function to strip the specific time out of the date
value before beginning the "bump" cycle:

dat = CDate(Fix(dat))

since you're beginning with a "Start" date and bumping that date by x number
of working days to get an "End" date, might i ask why you need to work with
time values?
>
Thanks again,

Connie

tina wrote:
okay, try this function, as

Public Function calcDate(ByVal dat As Date, ByVal intAdd As Integer) As
Date

Dim i As Integer, bump As Boolean, str As String

dat = CDate(Fix(dat))
i = 1

For i = 1 To intAdd
dat = dat + 1
Do
bump = False
If DCount(1, "tbl00Holidays" , "hDate = #" & dat & "#") 0
Then
dat = dat + 1
bump = True
End If

str = Format(dat, "ddd")
If str = "Sat" Then
dat = dat + 2
bump = True
ElseIf str = "sun" Then
dat = dat + 1
bump = True
End If
Loop Until bump = False
Next

calcDate = dat

End Function

the arguments are: a beginning date, and a number of days. the function
returns the calculated end date. the function uses a table that holds
holidays and any other dates (outside of weekends) that should not be
counted. the table is tbl00Holidays, and the date field is hDate - but of
course you can substitute the appropriate table and field names from your
holidays table.

hth
Hi Access Building Friends,
[quoted text clipped - 17 lines]
Thanks,
Connie

--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200809/1

Sep 10 '08 #7
Hi Tina,

Actually my Start_Date is a concatenation of the Start_Date and Start_Time.
That way it flows into a Start_Shift, and the time is in military time. So I
need an End_Time that would flow into an End_Shift. It is for a plastics
manufacturer.

Thanks so much! :)

Connie

tina wrote:
>comments inline.
>Hi Tina,

This code works great! Thank you so much. :)

you're welcome, glad it works for you. :)
>Could you tell me how to make it include the Start_Time and an End_Time?
I'm thinking it has to do with the "As Date" setting, but don't know how to
make it, "As Date/Time"

well, in Access, a date value stored as Date/Time data type *always* has a
time - a default of midnight, if nothing else. so the return value of the
function does include a time, but it is the default. in fact, i specifically
included code in this function to strip the specific time out of the date
value before beginning the "bump" cycle:

dat = CDate(Fix(dat))

since you're beginning with a "Start" date and bumping that date by x number
of working days to get an "End" date, might i ask why you need to work with
time values?
>Thanks again,
[quoted text clipped - 47 lines]
>Thanks,
Connie
--
Message posted via http://www.accessmonster.com

Sep 10 '08 #8
sorry, hon, you've completely lost me. i can't picture how you would
*concatenate* two date/time values - are your Start_Date and Start_Time
stored as Date/Time data type, or as Text data type? also, i don't
understand what you mean by "flows into"...?
"Connie via AccessMonster.c om" <u35472@uwewrot e in message
news:89fb48fbfe 751@uwe...
Hi Tina,

Actually my Start_Date is a concatenation of the Start_Date and
Start_Time.
That way it flows into a Start_Shift, and the time is in military time.
So I
need an End_Time that would flow into an End_Shift. It is for a plastics
manufacturer.

Thanks so much! :)

Connie

tina wrote:
comments inline.
Hi Tina,

This code works great! Thank you so much. :)
you're welcome, glad it works for you. :)
Could you tell me how to make it include the Start_Time and an
End_Time?
I'm thinking it has to do with the "As Date" setting, but don't know
how to
make it, "As Date/Time"
well, in Access, a date value stored as Date/Time data type *always* has
a
time - a default of midnight, if nothing else. so the return value of the
function does include a time, but it is the default. in fact, i
specifically
included code in this function to strip the specific time out of the date
value before beginning the "bump" cycle:

dat = CDate(Fix(dat))

since you're beginning with a "Start" date and bumping that date by x
number
of working days to get an "End" date, might i ask why you need to work
with
time values?
Thanks again,
[quoted text clipped - 47 lines]
Thanks,
Connie

--
Message posted via http://www.accessmonster.com

Sep 12 '08 #9
Hi Tina,

Oops! I guess I meant "add together" the date and time... So let's say the
Job Scheduler enters a Start Date of 9/12/08 and a Start Time of 22:30 (the
beginning of 3rd shift), I made a field called [Start_Date_Time] which just
adds the Start_Time to the Start_Date so I can use it in the calculation of
the End_Date_Time. Then I separate that into End_Date and End_Time so I can
use them in reports.

The calcDate retains the original time part of the Start_Time, and adds days
appropriately, but not the fraction of the last day.

I have been trying all day to get the code to show the time part. It seems
to be rounding down the intAdd to the nearest whole number.

By the way, I am working on a button to "Check Capacities" which will prevent
double booking of parts being scheduled to be built on machines.... which is
the main reason that I need the time part to show up is so they can know what
shift it will end on.

I really really appreciate your help.

Thank you.

Connie :)
tina wrote:
>sorry, hon, you've completely lost me. i can't picture how you would
*concatenate * two date/time values - are your Start_Date and Start_Time
stored as Date/Time data type, or as Text data type? also, i don't
understand what you mean by "flows into"...?
>Hi Tina,
[quoted text clipped - 36 lines]
>Thanks,
Connie
--
Message posted via http://www.accessmonster.com

Sep 12 '08 #10

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

Similar topics

5
6738
by: SimonC | last post by:
Help needed for a Javascript beginner. As above in the subject... i need a javascript to run this, but not in the form of a web-page. I want to calculate it between 2 fields in a database that i have extracted into a report writer. Look forward to hearing.. Cheers... SimonC
4
9341
by: Jan Szymczuk | last post by:
I'm creating an MS Access 2000 database where I have a number of people entered using simple basic fields, Surname: SMITH Forenames: John DoB: 09/09/1958 Age: (this needs to be automated to show years e.g. 46) I am trying to get the age to be automatically shown after a persons DoB (date of birth) is entered into the DoB field. I have tried using this formula in the Control Source of the Age field...
2
34351
by: Rustan | last post by:
Hi Im using GregorianCalendar to find out the current years week numbers. When the user chooses a week number in a dropdown i want to show that week in a table with the corresponding dates. For example : the user choses week43 (this week) so somehow i must calculate what date is startdate that week (monday 18th). How do i do this with c# ? all i know is that its-
9
3251
by: griemer | last post by:
Hi every one, Is there a way to calculate the timestamp of 00:00:00 last Sunday. For me, this is the begin of the current week.. Or, how old is this week, in seconds Any ideas? Regards,
6
14452
by: rohayre | last post by:
Im a long time java developer and actually have never done anything with java scripting. I'd like to write a short simple script for calculating a date in the future based on today's date and a letter. Can I use javascripting to create a webpage to allow a user to enter a letter and then click a button to find a future calendar date? I'm just not sure how much user interaction scripting allows. Does java scripting allow buttons, textfields...
9
2182
by: howzit | last post by:
I have a set date in my MySQL database that records when a Sales Lead is established and I echo that date as $row_rsLead; I need to be able to calculate how many days that lead has existed. $row_rsLead; outputs as 2007-06-14. I have made numerous attempts to create a function that will calculate the days between the lead_date and today's date, but have made absolutely no headway. I am either stuck working between differing date...
5
13671
by: Beemer Biker | last post by:
I cant seem to get that date into any DateTime to make my calculation directly by subtracting "01-01-0000" from "now". After reading this: http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=11469&objectType=File I kluged up this routine that works: // convert date time into that funny matlab serial date time that starts at jan 1, 0000 private string DT2Matlab(DateTime thisDT)
2
3180
by: viporyo | last post by:
I'm creating an Access Database 2003 for our Human Resource Dept. In the form, I will be adding a calendar wherein there will be date of hire, start date, etc. I need to be able to view the calendar to pick the date and I also need to auto calculate days. For example: if I start on 10/1/07, I need it to auto calculate on my next field +30, my next field will be +45 and my next field would be +90. What language do I use to do this and how do...
5
24554
FishVal
by: FishVal | last post by:
IMHO, the following is not a how-to-do instruction to solve a particular problem but more a concept-proof stuff demonstrating possibilities of SQL. So, let us say the problem is to calculate business days count which is defined as count of days (optionally inclusive in the current implementation) excluding weekend days and holidays. Let us say periods to calculate are stored in table associated with contacts. keyPeriodID -...
2
2336
by: shimul | last post by:
Hi All, If I set up a form with start date (choose from calendar) and end date. Each week Start date (Monday ) and want to automatically calculate end date (sunday each week) . how can I calculate an end date field and place it in the form, It really giving me hard time, can someone help please? As example start date : 2008/12/08, end date : 2008/12/14 Thank you.
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
10260
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
8933
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
7456
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
6712
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
5354
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...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
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
2850
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.