date format while inserting irrespective of regional settings

  • 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?

  • 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[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply