Hi there, I'm really hoping someone can help me with an issue I am having using the ‘DateDiffExclude’ command to work out the number of working days between two dates.
I have created a complaints database which is used to log all complaints coming into the company. Upon entering a Resolved Date I want the database to populate a field [Resolved_on_elapsed_day_number ] with the number of working days it took to complete the complaint. This is simply by calculating the difference between the date that the complaint was raised [add_date] and the date that the complaint was closed [Date_resolved]. I have the following code in place (this occurs whenever the [Date_resolved] field is changed)
__________________
Private Sub Date_resolved_Change()
Me.Resolved_on_elapsed_day_number = DateDiffExclude(me.add_date, Me.Date_resolved, "17")
DoCmd.Requery
End Sub
__________________
To my understanding the ‘17’ in the formula is to establish which dates are considered working days. 1 being Sunday, 7 being Saturday
The code is essentially working, but there are certain instances where it just returns a 0 as the value. For example.
[add_date] = 26/08/2010
[Date_resolved] = 01/09/2010
[Resolved_on_elapsed_day_number ]= 0
Whereas if I amend the [Resolved_on_elapsed_day_number ] field by one date it will display the correct result, for example:
[add_date] = 26/08/2010
[Date_resolved] = 02/09/2010
[Resolved_on_elapsed_day_number ]= 6
[add_date] = 26/08/2010
[Date_resolved] = 31/08/2010
[Resolved_on_elapsed_day_number ]= 4
It is annoying because the code works, it has proven that it works by giving the correct results in most cases and it accounts for weekends but then in some instances it just returns 0. Any help would be most appreciated as I am going round in circles now trying to find a solution to this.
Please see attached image for an example of the form being used.
I have created a complaints database which is used to log all complaints coming into the company. Upon entering a Resolved Date I want the database to populate a field [Resolved_on_elapsed_day_number ] with the number of working days it took to complete the complaint. This is simply by calculating the difference between the date that the complaint was raised [add_date] and the date that the complaint was closed [Date_resolved]. I have the following code in place (this occurs whenever the [Date_resolved] field is changed)
__________________
Private Sub Date_resolved_Change()
Me.Resolved_on_elapsed_day_number = DateDiffExclude(me.add_date, Me.Date_resolved, "17")
DoCmd.Requery
End Sub
__________________
To my understanding the ‘17’ in the formula is to establish which dates are considered working days. 1 being Sunday, 7 being Saturday
The code is essentially working, but there are certain instances where it just returns a 0 as the value. For example.
[add_date] = 26/08/2010
[Date_resolved] = 01/09/2010
[Resolved_on_elapsed_day_number ]= 0
Whereas if I amend the [Resolved_on_elapsed_day_number ] field by one date it will display the correct result, for example:
[add_date] = 26/08/2010
[Date_resolved] = 02/09/2010
[Resolved_on_elapsed_day_number ]= 6
[add_date] = 26/08/2010
[Date_resolved] = 31/08/2010
[Resolved_on_elapsed_day_number ]= 4
It is annoying because the code works, it has proven that it works by giving the correct results in most cases and it accounts for weekends but then in some instances it just returns 0. Any help would be most appreciated as I am going round in circles now trying to find a solution to this.
Please see attached image for an example of the form being used.