We’ve developed a large winforms application in .NET, and the client has requested to see the information in a different date format.
The problem we’ve encountered is that if we set the local regional settings to the client’s date format, SQL-code bombs out everywhere since the dates being passed to SQL aren’t in the same format anymore as SQL expects them.
Is there a way to get around this issue, without having to change my code everywhere, like this? MySqlProvider.SaveLoginDate(theDate.ToString(“dd/MM/yyyy”);
Preferably you should handle date formatting and date parsing in the user interface part of the code, so that you handle
DateTimevalues when you communicate with the database. Specify a culture or a format string when you format and parse dates.Also, storing the dates as UTC is a good idea if you have users in different time zones. Use the
ToLocalTimeandToUniversalTimeto convert between UTC and the local time zone.