Convert that date format mm/dd/yyyy to mm/dd/yy

Hello,
I want to convert a string mm/dd/yyyy into mm/dd/yy.
Can anyone help me with this?
I also want to convert dd-mon-yyyy into mm/dd/yy where mon is the month.

Hi @KeertiJ

Convert.todatetime(“dd/mmm/yyyy”)

Thanks
Ashwin.S

1 Like

Hey @KeertiJ

DateTime.Parse("Jun-06-2019").ToString("MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)  // Output -  06/06/2019

DateTime.Parse("06-Jun-2019").ToString("MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture) // Output -  06/06/2019


DateTime.Parse("06/6/2019").ToString("MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture) // Output -  06/06/2019

Regards…!!
Aksh

4 Likes

Thank you @aksh1yadav it was useful, but can you suggest how to convert ‘yyyy’ into ‘yy’ format ?

Hey @KeertiJ

Yes just replace yyyy to yy .

Regards…!!
AKsh