How to convert the String datatype date value in date("mmddyyyy") format?

Hi Team,

I have following value in string datatype

strDateValue = “12-02-2018”.

I have to convert this value in date format and need following output.

Output Value = “02122018”.
FYI - I have tried following options.

  1. Tostring(“mmddyyy”) - Not working
  2. Substring and cropping date. - Getting Output but it is not perfect way to do it.

Kindly assist me for same.

ConvertStringInDateFormat.xaml (4.5 KB)

HI @kawalkarhemant,

Refer this post.

use like this ToString("MMddyyyy")


Thank for your assistance. I have tried given solution but getting FormatException error.

PFA or Check below syntax which I have tried.

DateTime.ParseExact(strDataValue,“dd MM yyyy”,Globalization.CultureInfo.InvariantCulture).ToString(“MMddyyyy”)

Kindly assist.ConvertStringInDateFormat.xaml (5.2 KB)

I think you missed "-"
Give your correct date format


1 Like

Thanks a ton buddy. Got the solution.