I have this question since the dawn of my programming career. Is there really a culture neutral format for datetime in sql server so that when ever I'm sending query string from a client side to the database server running sql server 2008 side having different system datetime format, and if the query contains a date converted to a string, what format would not give me an error.
Culture: It is an optional parameter. By default, SQL Server uses the current session language for a default culture. We can provide a specific culture here, but the . Net framework should support it. We get an error message in case of invalid Culture.
The default string literal format, which is used for down-level clients, complies with the SQL standard form that is defined as YYYY-MM-DD. This format is the same as the ISO 8601 definition for DATE.
SQL Date Data Types TIMESTAMP - format: YYYY-MM-DD HH:MI:SS.
I recommend reading Tibor Karaszi's The ultimate guide to the datetime datatypes.
If you input your date/time in unseparated or ISO 8601 format, then you should be fine with any configuration.
Unseparated = 'yyyymmdd hh:mm:ss'
ISO 8601 = 'yyyy-mm-ddThh:mm:ss'
Update (from comments):
If you need to enter a date only (without the time part), then you have to use the 'YYYYMMDD'
format, as 'YYYY-MM-DD'
will not work. See the linked article for an example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With