Re: Workdays function with Australian Dates
- From: "Jeff" <jeff.pritchard@xxxxxxxxxxxx>
- Date: Thu, 16 Mar 2006 07:17:50 +1000
Format you date so -
Format(StartDate, "mm/dd/yyyy")
wherever you use a date in a query for comparison, and add a day so
DateAdd("d",1, StartDate)
This should help.
Jeff Pritchard
________________
Asken Research Pty. Ltd.
Access Database Developers
http://www.asken.com.au
"Dixie" <dixie@xxxxxxxxxxx> wrote in message
news:121grcql52u11d@xxxxxxxxxxxxxxxxxxxxx
I am trying to calculate the number of workdays between two dates with
regards to holidays as well. I have used Arvin Meyer's code on the Access
Web, but as I am in Australia and my date format is dd/mm/yyyy, I have
found that the dates I put in my holidays table are reversed into American
dates. So, the wrong holiday dates are subtracted from the total workdays
between the start and end dates. Is there an easy fix for this?
******Code follows******
Public Function WorkingDays2(StartDate As Date, EndDate As Date) As
Integer
'....................................................................
' Name: WorkingDays2
' Inputs: StartDate As Date
' EndDate As Date
' Returns: Integer
' Author: Arvin Meyer
' Date: May 5,2002
' Comment: Accepts two dates and returns the number of weekdays between
them
' Note that this function has been modified to account for holidays. It
requires a table
' named tblHolidays with a field named HolidayDate.
'....................................................................
On Error GoTo Err_WorkingDays2
Dim intCount As Integer
Dim rst As DAO.Recordset
Dim DB As DAO.Database
Set DB = CurrentDb
Set rst = DB.OpenRecordset("SELECT [HolidayDate] FROM tblHolidays",
dbOpenSnapshot)
'StartDate = StartDate + 1
'To count StartDate as the 1st day comment out the line above
intCount = 0
Do While StartDate <= EndDate
rst.FindFirst "[HolidayDate] = #" & StartDate & "#"
If Weekday(StartDate) <> vbSunday And Weekday(StartDate) <> vbSaturday
Then
If rst.NoMatch Then intCount = intCount + 1
End If
StartDate = StartDate + 1
Loop
WorkingDays2 = intCount
Exit_WorkingDays2:
Exit Function
Err_WorkingDays2:
Select Case Err
Case Else
MsgBox Err.Description
Resume Exit_WorkingDays2
End Select
End Function******End Code******
.
- Follow-Ups:
- Re: Workdays function with Australian Dates
- From: Dixie
- Re: Workdays function with Australian Dates
- References:
- Workdays function with Australian Dates
- From: Dixie
- Workdays function with Australian Dates
- Prev by Date: Is bypass (shift) key functionality from command line possible?
- Next by Date: Re: Compessing an Access database
- Previous by thread: Workdays function with Australian Dates
- Next by thread: Re: Workdays function with Australian Dates
- Index(es):
Relevant Pages
|