Soham Dasgupta
Soham Dasgupta

Reputation: 5199

What is the culture neutral dateformat for SQL Server

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.

Upvotes: 6

Views: 3953

Answers (2)

MicSim
MicSim

Reputation: 26796

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.

Upvotes: 13

Gaurav Gupta
Gaurav Gupta

Reputation: 5416

You could consider storing your date/times in UNIX time format.

Upvotes: 0

Related Questions