Hello,
I have variable date1=07/15/2020 (string Data Type with dd/MM/yyyy) .I want to convert date1 to dd/MM/yyyy format with DateTime Format.
I have tried Cdate and DateTime.ParseExact() but it doesn’t work
Hi @Maria_Baby1,
Please find the code below.
date2 = DateTime.ParseExact(date1, 'dd/MM/yyyy')
Warm Regards,
Ranjith Udayakumar
Hi,
Sorry it didn’t work.
date2= Date.Parse(date1.tostring) will return 07/15/2020 00:00;00
Regards,
Maria
Hi ranjith_udayakumar,
Sorry , it also didn’t work.’
Compiler error(s) encountered processing expression “DateTime.ParseExact(date1,“dd/MM/yyyy”)”.
Overload resolution failed because no accessible ‘ParseExact’ accepts this number of arguments.’
Regards,
Maria
@Maria_Baby1 The date you have used above is in MM/dd/yyyy format.
This Should work for it :
DateTime.ParseExact(“07/15/2020”,“MM/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)
Hi @Maria_Baby1,
Sorry My Bad.
DateTime.ParseExact(“07/15/2020”,“MM/dd/yyyy”, Nothing).ToString(“dd/MM/yyyy”)