Hi guys, I am trying to convert this date format dd/mm/yyy to format YYYY-MM-DD. And how do I change to date datatype? Cause I will need this datatype for database insertion.
@hjie30
Try with this
xmalDate=“dd/mm/yyy”
DateTime.ParseExact(xmlDate, "YYYY-MM-DD",
System.Globalization.CultureInfo.InvariantCulture)
@hjie30
Remove .tostring in expression and try
.ToString is requried else error will be prompted.
(DateTime.ParseExact(xmlDate, “YYYY-MM-DD”,
System.Globalization.CultureInfo.InvariantCulture)).ToString(“YYYY-MM-DD”)
I think I found where’s the error which that your answer given that you parse the source date string in wrong way, my source date format is dd/MM/yyyy and result is yyyy-MM-dd
So, I will have to use
DateTime.ParseExact(SpaDateLabel, “dd/MM/yyyy”, System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyy-MM-dd”)
Thank you! that solved my issue
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.