Extract datetime variable from a string, "20200408045500"

Hi All,

I have variable from excel in the format “20200408045500”.
Date from this variable is in the format YYYYMMDDHHMMSS
I want to convert it to dateTime Variable.
Please help

Hi @mohitkumar.gupta

Check this Convert string to date time - #3 by anil5

For the time, just add “hh:mm:ss”

Cheers

1 Like

in Assign,
Datetime YourDT = Datetime.ParseExact(YourStr, “yyyyMMddhhmmss”, nothing)

3 Likes

@mohitkumar.gupta Try this :
yourDateVar = DateTime.ParseExact(yourDateStr,“yyyyMMddHHmmss”,System.Globalization.CultureInfo.InvariantCulture)

Note that the date will be in the format MM/dd/yyyy HH:mm:ss

3 Likes

it works, Thanks @Dongjin_Lee

@supermanPunch it works, Thanks

1 Like

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