Date Time Conversion & Comparision

Hi,

This was my string from the excel, str1= “22/11/2019 23:59:43.642 GMT”, str2 = “18-Nov-19”, str3=“53:48.7”
I have to convert str1 as datetime1 and str4 as datetime2 with the format of (dd/MM/yyyy hh:mm:ss), (i.e.str4= str2 + str3).

And check datetime1 > datetime2.

Please help to crack this if possible.

Thanks & Regards,
@Spark_robot

Hi @Spark_robot,
What format has str3. Couldn’t recognize it.

0:53:48

Hi @Spark_robot,
Please refer the below code.

DateTime1 = DateTime.ParseExact(Str1,"dd/MM/yyyy HH:mm:ss.fff GMT",Nothing)
DateTime2 = DateTime.ParseExact(Str2+" "+Str3,"dd-MMM-yy HH:mm:ss.f",Nothing)

Refer below screenshot for comparision,
image

2 Likes

Hi @kuppu_samy

Thank you very much. Your code working fine.

Regards,
@Spark_robot

1 Like

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