Uipath convert date to time minutes

I am having two time span such as “13:00:04” and “15:45:45”
I want to get the difference in hours minutes and seconds

@Ritaman_Baral,

Try this approach with Assign activity

time1 = "13:00:04"
time2 = "15:45:45"
span1 = TimeSpan.Parse(time1)
span2 = TimeSpan.Parse(time2)
difference = span2 - span1
hours = difference.Hours
minutes = difference.Minutes
seconds = difference.Seconds

Sample Code:
TimespanDemo.xaml (7.4 KB)

Output:
image

Thanks,
Ashok :slight_smile:

Hi @Ritaman_Baral

You can use the below expression in assign activity,

- Assign -> timeSpan1 = TimeSpan.Parse("13:00:04")
- Assign -> timeSpan2 = TimeSpan.Parse("15:45:45")

- Assign -> differenceString = (timeSpan2 - timeSpan1).ToString("hh:mm:ss")

Hope it helps!!

In Addition to above we should keep in mind:
grafik
so we have to escape the : by \

for:
grafik

And can always recommend to do RnD within the immediate panel
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

Hi @Ritaman_Baral ,

Sample UiPath Workflow:

  1. Assign Activity:
  • startTime = "13:00:04"
  • endTime = "15:45:45"
  1. Assign Activity:
  • startTimeSpan = TimeSpan.Parse(startTime)
  • endTimeSpan = TimeSpan.Parse(endTime)
  1. Assign Activity:
  • difference = endTimeSpan - startTimeSpan
  1. Assign Activity:
  • hours = difference.Hours
  • minutes = difference.Minutes
  • seconds = difference.Seconds
  1. Write Line Activities:
  • Write Line: hours.ToString()
  • Write Line: minutes.ToString()
  • Write Line: seconds.ToString()
    Regards
    Sandy

hi @Ritaman_Baral

Here in one line

CStr(cdate(dat_ddMMyyyy).Hour-CDate(dat_dd_MM_yy).Hour) +":"+ Cstr(cdate(dat_ddMMyyyy).Minute-CDate(dat_dd_MM_yy).Minute) +":"+ CStr(cdate(dat_ddMMyyyy).Second-CDate(dat_dd_MM_yy).Second)

Where variables dat_ddMMyyyy = “15:45:45” and dat_dd_MM_yy = “13:00:04”
output As String.
Let me if any changes

Regards

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.