Rather than relying on configuration, consider changing your code to pass a specific culture.
For example:
yourDateTime.ToString("yyyy/MM/dd hh:mm:ss.fff", CultureInfo.InvariantCulture)
Or
yourDateTime.ToString("yyyy/MM/dd hh:mm:ss.fff", New CultureInfo("en-GB"))
UPDATE
Based on your comments below, I can offer the following advice:
Culture isn't relevant for this scenario. SQL Server doesn't store dates as strings, it stores them in types like
datetime
ordatetime2
ordatetimeoffset
. These types have no culture-specific attributes.You should never pass dates as strings when using SQL parameters. Pass them as
DateTime
orDateTimeOffset
types.You probably don't need to pass it at all, as you can just use
GETDATE()
orGETUTCDATE()
in SQL.I think what you mean is that when you look at the value in another tool like SQL Server Management Studio that you're seeing the output in a string with a particular format. That format has nothing to do with what is actually stored, only with how it is displayed. SQL has it's own settings for controlling that.