String not recognised as valid date time

Hi
I have a string deploy=“11/03/2019 5:00PM GMT”
I want to convert to specfic format 20190311

format=“dd/MM/yyyy”
convert_Date=DateTime.ParseExact(deploy.Split()(0).ToString,formatconversion,System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat).toString(yyyyMMdd) this var is of OBJ type.

3 Likes

you were almost done the expression will be like
DateTime.ParseExact(Split(deploy," ")(0).ToString,“MM/dd/yyyy”,System.Globalization.CultureInfo.invariantculture).tostring(“yyyyMMdd”)

Cheers @KarthikBallary

1 Like

Hi @KarthikBallary
Please see article below for your reference.

cheers :smiley:

Happy learning :smiley:

1 Like

what if the format is 3/23/2019
here m/dd/yyyy

Fine

will the format keeps changing or is the format M/dd/yyyy will be there
Cheers @KarthikBallary

dynamuc…keeps changing…MM/dd/YYYY but not dd/mm/yyyy it will be always month/date/year digit might be single or double

1 Like

how to convert 3/11/2019 to 00/00/0000 format 3/11/2019 is of type String

1 Like

awesome
then use this sequence to do this
–use a IF condition like this
str_input.Length.Equals(10)
if this is true it will go to THEN part where use this expressiion
DateTime.ParseExact(Split(deploy," ")(0).ToString,“MM/dd/yyyy”,System.Globalization.CultureInfo.invariantculture).tostring(“yyyyMMdd”)

or if its false it will go to ELSE part where use this expression
DateTime.ParseExact(Split(deploy," ")(0).ToString,“M/dd/yyyy”,System.Globalization.CultureInfo.invariantculture).tostring(“yyyyMMdd”)

Cheers @KarthikBallary

2 Likes

thank you

1 Like

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