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.
Tostring(“mmddyyy”) - Not working
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)
arivu96
(Arivazhagan A)
March 2, 2018, 7:29am
2
HI @kawalkarhemant ,
Refer this post.
Hi @krishnan
Use this code
str_date = DateTime.ParseExact("29 Aug 2017","dd MMM yyyy",Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")
Regards,
Arivu
kawalkarhemant:
Tostring(“mmddyyy”)
use like this ToString("MMddyyyy")
Regards,
Arivu
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)
arivu96
(Arivazhagan A)
March 2, 2018, 8:20am
4
kawalkarhemant:
“12-02-2018
I think you missed "-"
Give your correct date format
DateTime.ParseExact(strDataValue,"dd-MM-yyyy",Globalization.CultureInfo.InvariantCulture).ToString("MMddyyyy")
Regards,
Arivu
1 Like
Thanks a ton buddy. Got the solution.