I am calculating time difference between 2 time stamps in hours: min :sec format .
Now my problem is I have to eliminate weekends between 2 time stamps and calculate difference in hours: min :sec format
Discussion posts and replies are publicly visible
Hello likhithan
You can test out the calworkdays(). Here is a reference for documentation calworkdays(). Have you tried converting epoch values and calculate when it comes to seconds? It would return epoch seconds and you can convert into days.
hilikhithan calworkdays you can use this function
I have tried calworkdays() but no use becasue when I have time stamp with in same day lets say [3/11/2024 9:24 AM EDT] and [3/11/2024 9:26 AM EDT] then here the difference is just 2 min right . But when I use this function, days will be coming as 1 but difference between these two dates we cannot expect days as 1
Then I would say epoch conversions and calculations will definetely help.
What is this epoch conversions could you please explain
Here is a reference where you can check the conversions. and create a custom expression rule to evaluate accordingly.Epoch Converter
a!localVariables( local!MaxDateTimeForAssigned: todatetime( rule!ERR_GetMaxDateTimeByStatus( statusId: cons!ERR_STATUS[3], trackingId: ri!trackingId ) ), local!MaxDateTimeForWaitingApproval: todatetime( rule!ERR_GetMaxDateTimeByStatus( statusId: cons!ERR_STATUS[5], trackingId: ri!trackingId ) ), local!CycleTime: if( or( a!isNullOrEmpty(local!MaxDateTimeForAssigned), a!isNullOrEmpty(local!MaxDateTimeForWaitingApproval) ), {}, local!MaxDateTimeForWaitingApproval - local!MaxDateTimeForAssigned, ), local!format: if( a!isNullOrEmpty(local!CycleTime), {}, split(local!CycleTime, ".")[1], ), local!days: if( a!isNullOrEmpty(local!format), {}, split(local!format, "::")[1], ), local!hours: if( a!isNullOrEmpty(local!format), {}, if( local!days = 0, split(local!format, ":")[3], sum( (local!days * 24), split(local!format, ":")[3] ) ) ), local!min: if( a!isNullOrEmpty(local!format), {}, split(local!format, ":")[4] ), local!sec: if( a!isNullOrEmpty(local!format), {}, split(local!format, ":")[5] ), local!TotalCycleTime: { if( and( a!isNullOrEmpty(local!hours), a!isNullOrEmpty(local!min), a!isNullOrEmpty(local!sec) ), {}, local!hours & ":" & local!min & ":" & local!sec ) }, local!TotalCycleTime )
This will not be coming in hours:min: sec format . i already have rule where I can get difference between time stamps but my only problem is to eliminate weekend and get in the hours: min: sec format as output
Yes. You will have to construct your expression rule to calculate the difference based on the below valuesAlso I would say try out these for better understanding
I can understand the above mentioned way is a complex one. But the conversion of your date times will give you accurate values.
Can you please check my code. I have sent . The way you are saying like how can I eliminate weekends there
i think then you need to calculate works hours initially