How to convert Date format from Jun 1,2019 to dd-MM-yyyy

I have a format of date in Jun 1,2019 string variable need to convert into dd-MM-yyyy DateTime variable .

datetime = Convert.ToDateTime(string)

I have date in this format Jun 1,2019 or it can be Aug 25,2020 but i need those date in 01-06-2019 and 20-08-2020 respectively .

Hi try this ,

Convert.todatetime(yourdate). tostring(“dd-MM-yyyy”)

Or

Cdate(yourdate). tostring(“dd-MM-yyyy”)

Hi Updated syntax and i have tested it,

Pass the date as variable.

DateTime.ParseExact(“AUG 25,2020”,“MMM dd,yyyy”,Globalization.CultureInfo.InvariantCulture).ToString(“dd-MM-yyyy”)

@prasath_S
Thank you it worked

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