Link to home
Start Free TrialLog in
Avatar of cwickens
cwickensFlag for United States of America

asked on

DateDiff question, need count for 8 hours a day including weekends and holidays

Should be pretty simple really, but I am in brainfart mode this am (pardon the expression), lack of caffeine again, I suppose...

I have two dates (startDate and endDate), they represent when a ticket is opened and closed.  There will be a third field to be used later for 'workTime'.  

For each day (24 hour period) in the dateDiff (including holidays and weekends), I need to add 8 hours, then when I have the final number, I need to subtract the value of the 'workTime' field.

chuck
Avatar of nmxsupport
nmxsupport

Avatar of cwickens

ASKER

It looks like this is only available in MS Project/VBA.  I am using it in a Web App with VB,

Any thoughts on using dateDiff and converting it or a VB example of projectDateDiff?
ok, I am making progress...  I can use the dateDIff and return the number of days, hours, minutes and seconds.

I get the result as 3.13:30:00  (3 days, 13 hours, 30 minutes, 0 seconds).  I need to parse that result into: 24 (3 8 hour periods) + 8 (in the 13 hour block)  + .5 (for the 30 minute) = 32.5

ugh....thoughts anyone?
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim startDate As DateTime = Me.RadStartDateTimePicker.SelectedDate
        Dim endDate As DateTime = Me.RadStartDateTimePicker0.SelectedDate
        Dim totalTime As String = ""
 
        totalTime = endDate.Date.Subtract(startDate).ToString
        Me.LabelTotalTime.Text = totalTime
    End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of cwickens
cwickens
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial