Thursday, October 13, 2016

Convert dates to MM/dd/yyyy format


C# function that converts different date formats to MM/dd/yyyy



In my database, there was a date formatting problem. Dates were stored in the following formats M/d/yyyy (eg. 9/9/2009) , M/dd/yyyy (e.g. 9/09/2009), MM/d/yyyy (e.g. 09/9/2009) and MM/dd/yyyy (e.g. 09/09/2009). This was a problem especially since we required the user to enter their date of birth at the time of first login. Therefore, I created the above function to convert all dates to the MM/dd/yyyy format.