String to Date issue

How can I transfer “Feb 14, 2021” to “2021/2/14”?


Can you try the following expression?

DateTime.ParseExact(yourString,"MMM d, yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("yyyy/M/d")


1 Like

You can use this below code, @Chen_Kenny
Cdate(“Feb 14, 2021”.Replace(",","")).ToString(“yyyy/M/dd”)
Hope this may help you :slight_smile:

1 Like

I think @Yoichi

It should be like this

DateTime.ParseExact(yourString,“MMM dd, yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyy/M/dd”)

Instead of d it would be dd

Correct me if I’m wrong


Nived N :robot:

Happy Automation :relaxed::relaxed::relaxed:

1 Like


Both will work for the above input string.
The difference is : If we set d in ParseExact, (for example)"Feb 7, 2021" and "Feb 07, 2021" both will be valid. However if we set dd, only Feb 07, 2021 will be valid.
And output style will be also different like 2021/2/7 and 2021/2/07.

Which is better depends on the requirements.



Hi @Yoichi

Thanks for response :blush:

1 Like

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