Needed help in converting date and time to milliseconds

Hi Experts,

I was trying to convert the following date and time format to milliseconds but facing some problem please can any one help me out with this

Nov 7, 2019 2:10:02 PM CET

Thanks in advance.

Regards,
Vikram

Hi @vikram.g,

Can you please in which format you want output.

Thanks.

Hi,

Thanks for the replay, i need output in milliseconds.

Regards,
Vikram

Hi
Welcome back to uipath community
If the input is in this format
str_input =“Nov 7, 2019 2:10:02 PM CET”
Then the expression
TimeSpan.Parse(split(str_input,” “)(3)).TotalMilliSeconds
Will give us the milliseconds

Cheers @vikram.g

1 Like

Well,

Parse exact the above string for your date time format variable and then use the following to convert to milliseconds

DirectCast((Datetime.Now - New DateTime(1970, 1, 1)).TotalMilliseconds, Int64)

or

CLng((Datetime.Now - New DateTime(1970, 1, 1)).TotalMilliseconds)

or

(DateTime.Now-new DateTime(1970,1,1)).TotalMilliseconds

for more advanced conversiosn and info visit - https://docs.microsoft.com/en-us/dotnet/api/system.datetime.ticks?redirectedfrom=MSDN&view=netframework-4.8#System_DateTime_Ticks

1 Like

@Palaniyappan @Raghavendraprasad thanks guys for your inputs.

Aftering converting to milliseconds i need to compare between 2 date and time and need to find out the difference,

For example str1: Nov 7, 2019 2:10:02 PM CET
str2: Nov 7, 2019 2:09:02 PM CET
Now i need to find the time difference between this two strings.Can you please help me with this.

Thanks in advance

Regards.
Vikram

Fine
hope this expression wouldd help you resolve this
str1: Nov 7, 2019 2:10:02 PM CET
str2: Nov 7, 2019 2:09:02 PM CET

then time difference will be like this
(Datetime.ParseExact(split(variable1.ToString,“PM”)(0).ToString.Trim,“MMM d, yyyy h:mm:ss”,System.Globalization.CultureInfo.InvariantCulture)-
Datetime.ParseExact(split(variable2.ToString,“PM”)(0).ToString.Trim,“MMM d, yyyy h:mm:ss”,System.Globalization.CultureInfo.InvariantCulture)).TotalDays.ToString

Cheers @vikram.g

2 Likes

Solution Machine - @Palaniyappan

:grinning::smiley::muscle: Keep up the good work…!

1 Like

here you go a sample xaml
hope its resolved
vikram.zip (1.9 KB)

Cheers @vikram.g

1 Like

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