String to date time

Hi All,

need vb.net code to convert from string to date

for example : Tuesday, September 19 by 7:00 P.M

output: 09/19/2023 19:00.

Thanks,
Veera

Hi @veeramani.shanmugam ,
Cdate(yourString).Tostring(“MM/dd/yyyy hh:mm tt”)
regards,

Thanks for your quick help. But getting below error

Cdate(“September 19 by 7:00 P.M”).Tostring(“MM/dd/yyyy hh:mm tt”)

Assign: Expression Activity type ‘VisualBasicValue`1’ requires compilation in order to run. Please ensure that the workflow has been compiled.

@veeramani.shanmugam

DateTime.ParseExact(“Tuesday, September 19 by 7:00 P.M”, “dddd, MMMM d ‘by’ h:mm tt”, System.Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy HH:mm”)

Hi,

Can you try the following expression?

DateTime.ParseExact(yourString.Replace(".",""),"dddd, MMMM d \b\y h:m tt",System.Globalization.CultureInfo.InvariantCulture).ToString("MM/dd/yyyy HH:mm")

Regards,

@Yoichi - Thanks a lot :slight_smile:

1 Like

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