Hello all,
-My goal is to count the number of days between two dates excluding holidays and weekends, then send those results to a new table each month.
-Here is my situation and problem. I’ve written my entire program in Access 2000 w/o having to write any code. So I really don’t know anything about using a function and will need some help trying to implement this. But I think I need to “some-how” run my date fields through a function I have found, and then “some-how” send the results to a new table.
-The function I have found is from this forum. When I create a module and paste the function into the VB Editor and use the Immediate Window, I get results like:
? 7/30/2002 9/16/2002
1.16550116550117E-04 2.80969030969031E-04
? 1/1/2001
4.99750124937531E-04
-I don’t know what this is or what to do with it or if it is even right. I created a table called tblHolidays. It has two fields called Holidays(text) & HoliDate(date/time). I have 9/4/2002 in there.
Here’s the function I’m trying to use:
“Calculating the workdays between Dates”
' Note that this function does account for holidays.
Dim WholeWeeks As Variant
Dim DateCnt As Variant
Dim EndDays As Integer
BegDate = DateValue(BegDate)
EndDate = DateValue(EndDate)
DateCnt = BegDate
EndDays = 0
Do While DateCnt <= EndDate
If Not IsNull(DLookup("HoliDate", "tblHolidays", "[HoliDate]=#" & DateCnt & "#")) Then
EndDays = EndDays - 1
End If
If Format(DateCnt, "ddd") <> "Sun" And _
Format(DateCnt, "ddd") <> "Sat" Then
EndDays = EndDays + 1
End If
DateCnt = DateAdd("d", 1, DateCnt)
Loop
Work_Days = EndDays
End Function
-Here are the details in my access db:
Main table name = 10_Consumer
Main table fields = Alert_Date_Referral ie. Date: 7/30/2002
Sent_to_State_Fax ie. Date: 8/16/2002
Received_from_State ie. Date: 9/11/2002
Start_of_Care ie. Date: 9/16/2002
Full_Name ie. Name: Doe,John
-The math I need to do is as follows and I can currently do with a query in access:
DAYS_FOR_US_TO_SEND_TO_STATE:[Sent_to_State_Fax]-[Alert_Date_Referral]
DAYS_FOR_STATE_TO_COMPLETE:[Received_from_State]-[Sent_to_State_Fax]
DAYS_FOR_US_TO_START_CARE:[Start_of_Care]-[Received_from_State]
TOTAL_DAYS_FOR_US_TO_COMPLETE[Sent_to_State_Fax]-[Alert_Date_Referral])+([Start_of_Care]-[Received_from_State])
TOTAL_DAYS_FOR_PROCESS[Sent_to_State_Fax]-[Alert_Date_Referral])+([Received_from_State]-[Sent_to_State_Fax])+([Start_of_Care]-[Received_from_State])
-The answers I can get are:
DAYS_FOR_US_TO_SEND_TO_STATE: 17
DAYS_FOR_STATE_TO_COMPLETE: 26
DAYS_FOR_US_TO_START_CARE: 5
TOTAL_DAYS_FOR_US_TO_COMPLETE: 17+5=22
TOTAL_DAYS_FOR_PROCESS: 17+26+5=48
-But the answers I need exclude holidays and weekends (holiday on 9/4) and are:
DAYS_FOR_US_TO_SEND_TO_STATE: 13 (I do count 7/30 and don’t count 8/16)
DAYS_FOR_STATE_TO_COMPLETE: 17
DAYS_FOR_US_TO_START_CARE: 4
TOTAL_DAYS_FOR_US_TO_COMPLETE: 13+4=17
TOTAL_DAYS_FOR_PROCESS: 13+17+4=34
-I then need to create a table with these results including the consumer name each time I do this, which will be once a month.
-I hope this is what you will need to help me. Thank you in advance!
Brad Garrett
-My goal is to count the number of days between two dates excluding holidays and weekends, then send those results to a new table each month.
-Here is my situation and problem. I’ve written my entire program in Access 2000 w/o having to write any code. So I really don’t know anything about using a function and will need some help trying to implement this. But I think I need to “some-how” run my date fields through a function I have found, and then “some-how” send the results to a new table.
-The function I have found is from this forum. When I create a module and paste the function into the VB Editor and use the Immediate Window, I get results like:
? 7/30/2002 9/16/2002
1.16550116550117E-04 2.80969030969031E-04
? 1/1/2001
4.99750124937531E-04
-I don’t know what this is or what to do with it or if it is even right. I created a table called tblHolidays. It has two fields called Holidays(text) & HoliDate(date/time). I have 9/4/2002 in there.
Here’s the function I’m trying to use:
“Calculating the workdays between Dates”
' Note that this function does account for holidays.
Dim WholeWeeks As Variant
Dim DateCnt As Variant
Dim EndDays As Integer
BegDate = DateValue(BegDate)
EndDate = DateValue(EndDate)
DateCnt = BegDate
EndDays = 0
Do While DateCnt <= EndDate
If Not IsNull(DLookup("HoliDate", "tblHolidays", "[HoliDate]=#" & DateCnt & "#")) Then
EndDays = EndDays - 1
End If
If Format(DateCnt, "ddd") <> "Sun" And _
Format(DateCnt, "ddd") <> "Sat" Then
EndDays = EndDays + 1
End If
DateCnt = DateAdd("d", 1, DateCnt)
Loop
Work_Days = EndDays
End Function
-Here are the details in my access db:
Main table name = 10_Consumer
Main table fields = Alert_Date_Referral ie. Date: 7/30/2002
Sent_to_State_Fax ie. Date: 8/16/2002
Received_from_State ie. Date: 9/11/2002
Start_of_Care ie. Date: 9/16/2002
Full_Name ie. Name: Doe,John
-The math I need to do is as follows and I can currently do with a query in access:
DAYS_FOR_US_TO_SEND_TO_STATE:[Sent_to_State_Fax]-[Alert_Date_Referral]
DAYS_FOR_STATE_TO_COMPLETE:[Received_from_State]-[Sent_to_State_Fax]
DAYS_FOR_US_TO_START_CARE:[Start_of_Care]-[Received_from_State]
TOTAL_DAYS_FOR_US_TO_COMPLETE[Sent_to_State_Fax]-[Alert_Date_Referral])+([Start_of_Care]-[Received_from_State])
TOTAL_DAYS_FOR_PROCESS[Sent_to_State_Fax]-[Alert_Date_Referral])+([Received_from_State]-[Sent_to_State_Fax])+([Start_of_Care]-[Received_from_State])
-The answers I can get are:
DAYS_FOR_US_TO_SEND_TO_STATE: 17
DAYS_FOR_STATE_TO_COMPLETE: 26
DAYS_FOR_US_TO_START_CARE: 5
TOTAL_DAYS_FOR_US_TO_COMPLETE: 17+5=22
TOTAL_DAYS_FOR_PROCESS: 17+26+5=48
-But the answers I need exclude holidays and weekends (holiday on 9/4) and are:
DAYS_FOR_US_TO_SEND_TO_STATE: 13 (I do count 7/30 and don’t count 8/16)
DAYS_FOR_STATE_TO_COMPLETE: 17
DAYS_FOR_US_TO_START_CARE: 4
TOTAL_DAYS_FOR_US_TO_COMPLETE: 13+4=17
TOTAL_DAYS_FOR_PROCESS: 13+17+4=34
-I then need to create a table with these results including the consumer name each time I do this, which will be once a month.
-I hope this is what you will need to help me. Thank you in advance!
Brad Garrett
Last edited: