May 1, 2014 at 12:56 am
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?
May 1, 2014 at 4:12 am
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.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply