Solved Count Number of dates (1 Viewer)

Number11

Member
Local time
Today, 09:25
Joined
Jan 29, 2020
Messages
607
So I need to count the number of days by date and show something like

Total Days unworked
Total Records unworked

NumberOfWorkingDays:
[EndDate]-[StartDate]

so end date would be the last date and the start date would be the oldest?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:25
Joined
May 7, 2009
Messages
19,172
you can also do a Loop, and disregard if the date is Weekend (Sat, Sun):
Code:
public function udfWorkDays(dtStart As Date, dtEnd As Date)
Dim i As Integer
Dim dt As Date
For dt = dtStart To dtEnd
    If Instr("Sat/Sun", Format(dt, "ddd")) = 0 Then
        ' do not include Sat and Sun
        i = i + 1
    End If
Next
udfWorkDays = i
End Function
 

zeroaccess

Active member
Local time
Today, 04:25
Joined
Jan 30, 2020
Messages
671
Date is recorded in number of days, so you should just be able to do date - date.

If your dates are in combo boxes, in a query, you could do:

NumberOfWorkingDays: ([Forms]![frmHome]![txtEndDate]-[Forms]![frmHome]![txtStartDate])

If they are coming from fields in your query:

NumberOfWorkingDays: ([EndDate]-[StartDate])
 
Last edited:

Users who are viewing this thread

Top Bottom