Skip to main content
April 2, 2024
Solved

How to get working days between 2 time stamps

  • April 2, 2024
  • 24 replies
  • 1 view

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  

    Best answer by mikes0011

    CalWorkDays calculates days not as elapsed but on an "inclusive" basis, meaning if the start and end times are both "now" then it'll return 1 day, and so on when more days are added.  Maybe you should try subtracting 1 from the overall result you're getting and seeing if that lines up with your expected values given different inputs.

    24 replies

    konduruc733182
    April 2, 2024

    Hello [mention:fd7875ff7e5f47849b21055e357cd8e2:e9ed411860ed4f2ba0265705b8793d05] 

    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. 

    likhithanAuthor
    April 2, 2024

    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

    konduruc733182
    April 2, 2024

    Then I would say epoch conversions and calculations will definetely help.

    karumurua531442
    April 2, 2024

    hi[mention:fd7875ff7e5f47849b21055e357cd8e2:e9ed411860ed4f2ba0265705b8793d05]  calworkdays you can use this function 

    April 2, 2024

    Hello

    calworkdays(datetime(2024, 4, 1, 00, 00, 0), datetime(2024, 4, 7, 00, 00, 0))

    likhithanAuthor
    April 2, 2024

    My problem while is if I have only 3 min difference between 2 dates , but by using this function I am getting 1 day as working day in the case where timestamp is in same date

    mikes0011
    mikes0011Answer
    Brainy
    April 2, 2024

    CalWorkDays calculates days not as elapsed but on an "inclusive" basis, meaning if the start and end times are both "now" then it'll return 1 day, and so on when more days are added.  Maybe you should try subtracting 1 from the overall result you're getting and seeing if that lines up with your expected values given different inputs.

    The Expression Guru