My application work with SQL Server and it works with different servers with different culture infos (for example Ru-Ru, En-US, etc.) … How can I insert data value to it? I need to convert my DateTime to string depends on server’s culture, but how?
My application work with SQL Server and it works with different servers with different
Share
For
culture Specific conversionyou can use:But if you really can’t decide what culture to use when converting dates to strings and vice-versa, and the dates are never meant to be shown to a user, then you can use the
Invariant Culture:And if you are converting your dates and saving them as strings you can use
ISO-8601 date formati.eYYYYMMDDorYYYYMMDD HH:MM:SS, this will always work, regardless of currently selected language or culture settings in SQL Server.The following
Stackoverflowquestion may help you:Reference: DateTime issue when global culture of the server is different on different servers
Hope this helps.