Hi @william.coulson,
use below format
"dd/MM/yyyy hh:mm:ss tt"
Regards,
Arivu
That’s worked, thank you. Do I need to use FinishTime - StartTime to get a total time? FinishTime.Subtract(StartTime) has a validation error.
can you send the error screenshort
TotalTimeSpan= **FinishTime.Subtract(StartTime)**
Make it both the variable are datetime format.
Else convert to date format
Convert.ToDateTime(FinishTime).Subtract(Convert.ToDateTime(StartTime))
Regards,
Arivu
Hey @arivu96,
The solution you’ve given me isn’t working now. Any ideas why? Have tried with FinishTime and StartTime as String and GenericValue and neither worked.
This is the error…
At the moment, I am getting StartDate and Finish Date from DateTime.Now.ToString(“dd/MM/yyyy hh:mm:ss”). I need to get a total time from subtracting these two variables. I am using @arivu96’s solution:
Which is coming up with an error, screenshotted above
Great
so the expression be like this for different scenarios
date_start = Datetime.ParseExact(StartDate.ToString,“dd/MM/yyyy hh:mm:ss”,System.Globalization.CultureInfo.InvariantCulture)
date_finish = Datetime.ParseExact(StartDate.ToString,“dd/MM/yyyy hh:mm:ss”,System.Globalization.CultureInfo.InvariantCulture)
date_start and date_finish is a variable of type System.Datetime
nw
for day difference
int_date = (date_start-date_finish).TotalDays
for minutes difference
int_minutes = (date_start-date_finish).TotalMinutes
for seconds difference
int_seconds = (date_start-date_finish).TotalSeconds
Cheers @william.coulson
I have set the date format to dd/MM/yyyy and it is still outputting as MM/dd/yyyy. Time is correct though.
StartDate is date_start
That’s worked, thank you. I will resolve my Total Time issue by using DateTime in another assign activity.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.