Format Days To Hours

J

jlo

In the past, I have used a formula to calculate how many work days has
occurred between date fields. I track days excluding Holidays and Weekends
from code I received years back from this discussion group. Everything works
wonderful.

I have another situation similiar but the user wants to track time as well
as the number of days excluding Holidays and Weekends. Is there a way to
format this formula CalcWorkDays([DateTimeReceived],[DateTimeAcknowledged])
so I can get hh:mm:ss? Currently I am get 1 day. Is there a way to format 1
day to 15 minutes or should I use another public function?

For instance:
DateTimeReceived DateTimeAcknowledged
4/4/08 10:00 am 4/4/08 10:15 am

Here is the code:
Function CalcWorkDays(dtmStart As Date, dtmEnd As Date) As Integer
Dim intTotalDays As Integer ' Counter for number of days
Dim dtmToday As Date ' To increment the date to compare
'Compliments of Dave Hargis

intTotalDays = DateDiff("d", dtmStart, dtmEnd) + 1 'Start with total days
'Add one to include
First Day
dtmToday = dtmStart 'Initiate compare date
Do Until dtmToday > dtmEnd
If Weekday(dtmToday, vbMonday) > 5 Then 'It is Saturday or
Sunday
intTotalDays = intTotalDays - 1 'Take one day away
ElseIf Not IsNull(DLookup("[Holdate]", "Holidays", _
"[Holdate] = #" & dtmToday & "#")) Then 'It is a holiday
intTotalDays = intTotalDays - 1 'Take one day away
for the Holiday
End If
dtmToday = DateAdd("d", 1, dtmToday) 'Add a day for next
compare
Loop 'Until dtmToday > dtmEnd 'All days have been
compared
CalcWorkDays = intTotalDays 'Return the value

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Calcworkdays Revision? 2
Calculating Date/Time Fields 1
Counting Workdays Function 1
Calculate Buisness Days Open 2
CalcWorkDays error 2
Can't query DateDiff 0
Format a Calculated Field 0
Number of days 9

Top