Concevrt string into date fromat

hi,
I am getting the received timestamp from mail activity but its stored in string variable. I am unable to subtract from DateTime.Now output because its datetime .

let me know how we can do it

Hello,

please try to use this expression:

Date.ParseExact(YourString,“dd/MM/yy”,System.Globalization.CultureInfo.InvariantCulture)
“dd/MM/yy” - desribes the format in which date was saved as string

Then you can substract two DateTime variables.

Regards

hi,
Datetime.Today.AddYears(-1).ToString(“MM/dd/yyyy”)try to use this syntax for subtracting

Regards,

hi,
I will try above one just clarity from mail I am getting date in (05/03/2019 11:01:16) this format

getting validation error.

At what stage exactly? Could you go into details or attach workflow?

Please find screens of my example workflow:

Output:
image

Regards

1 Like

CalculateTimeDiff.xaml (5.2 KB)
hi,

Uploaded the workflow ,please check

Please make variable currentTM in type DateTime, not Date.
Refer to my post above. (With usage of conversion of D2 variable)

Regards

I am reading that values from excel/mail received timestamp which gives output in string.
If change the type it will give error on excel values store.

Read this value from Excel as string, and save it with conversion (which I have posted above) to a new DateTime variable. And this new variable subtract from DateTime.Now

Or simply do:
DateTime.Now - Date.ParseExact(D2,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture)
where D2 is your string variable from excel file.

Regards

Capture
we are getting the above error

Hey @kiranh

Try This: - CalculateTimeDiff.xaml (4.7 KB)

A TimeSpan value represents a time interval and can be expressed as a particular number of days, hours, minutes, seconds, and milliseconds.
Tt represents a general interval without reference to a particular start or end point, it cannot be expressed in terms of years and months, both of which have a variable number of days.

Regards…!!
Aksh

1 Like

AAAH yes timestamp is different with datetime na…very bad…my mistake
Thats great
cheers buddy @aksh1yadav
@kiranh

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