can use help:
- calculating the time difference between dates (“dd/MM/yyyy”)- in days
- calculating the time difference between dates(“dd/MM/yyyy hh:mm:ss”) -in hours/minutes/seconds
can use help:
(Date.ParseExact(endDate, "dd/MM/yyyy", Nothing)-Date.ParseExact(startDate, "dd/MM/yyyy", Nothing)).Days
Here startDate and endDate are string variable holding date in dd/MM/yyyy format
(DateTime.ParseExact(endDate, "dd/MM/yyyy hh:mm:ss", Nothing)-DateTime.ParseExact(startDate, "dd/MM/yyyy hh:mm:ss", Nothing)).Duration
should the variables be with ending like:
if the one of the variable is System.DateTime.Now.ToString(“dd/MM/yyyy hh:mm:ss”)
For the output you can use .ToString
an error rises:
(DateTime.ParseExact(System.DateTime.Now, “dd/MM/yyyy hh:mm:ss”, Nothing)-DateTime.ParseExact(Process_Start_Time_Stamp, “dd/MM/yyyy hh:mm:ss”, Nothing)).Duration.tostring
What is the data type of Process_Start_Time_Stamp? Check in variable panel
Also, For System.DateTime.Now there is no need to use DateTime.ParseExact
Also, Check what is the output if you type System.DateTime.Now in log message activity.
Simply use this
(Now-DateTime.ParseExact(Process_Start_Time_Stamp, "dd/MM/yyyy hh:mm:ss", Nothing)).Duration.ToString
wow thank you!
you gave me a lot of good advice
how can i change the output format? (it took close to 15 seconds and the output is:
it will give you seconds
For the whole string
Join(durationString.Split(":"c).Select(Function (x) Math.Round(CDbl(x),0).ToString).ToArray, ":")
Or better use this
System.Text.RegularExpressions.Regex.Replace(durationString, "\d+\.\d+$", Math.Round(CDbl(durationString.Split(":"c).Last), 0).ToString)
durationString = "12:00:14.7405741", i.e., the difference output
the 14.7405741 is fine by me but not the 12:00 before that, is there a solution?
What is the output you want?
because it is showing you the correct difference between two dates.
here 12 is for hours
The difference between the two dates is not 15 seconds that’s why 12 is appearing. It is hh:mm:ss format.
you are right, but i am running this from Now to 15 second ago,why is the 12 is showing?
What is the code you are using?
Send the screenshot of your workflow
There is no need to convert Now to a String if you want to calculate the difference.
Simply use like this
I have changed the workflow. Please check it.
Date Diff.xaml (5.1 KB)
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.