SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


date format while inserting irrespective of regional settings


date format while inserting irrespective of regional settings

Author
Message
tirthadip
tirthadip
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 14
as per my understanding If I pass a date to sql server to insert it will parse the date on the basis of the regional settings of the machine where sql-server is installed. For example if I pass a date as "10/01/2000" and the regional setting is "dd/MM/yyyy" then sql-server will insert the date as "10th January 2000" and if the regional setting is "MM/dd/yyyy" then "1st October 2000" will be inserted. Am I right?....Please bear with me as I am not proficient in SQL-SERVER....if this is the case then prior to writing code I have to be confirmed about sql-server machine regional settings......Is there a way that I can send SQL-SERVER the format also?
LutzM
LutzM
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10697 Visits: 13559
It doesn't depend on the SQL Server setting but on the setting of the date format setting at the point the INSERT statement.
It is influenced by the following settings:
SET DATEFORMAT
SET LANGUAGE
The language setting of the user running the command / batch / sproc
The server setting

If you want to avoid dealing with different settings for date format, I'd recommend to use the ISO standard: YYYMMDD HH:MM:SS.
So, instead of sending "10/01/2000" you should either use "20000110" or "20001001", depending on the date it refers to.
This will always convert to the same date, regardless of the settings mentioned above.



Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search