locale and datetimes

  • Does SQL automatically adjust dates to the locale of the connection. I am querying a server in one time zone from another and getting inconsistent results between datetime values before and after the clocks went forward in the UK.

    Thanks

    Buzz

  • [font="Verdana"]I'm not sure, but I think that it does so, yes.

    It should be fairly easy to put together a test and run it across your different locales to see what results you get.

    SQL Server 2008 has a concept of "universal time" I believe to help alleviate this issue.

    [/font]

  • I actually disagree with Bruce on this one, sorry Bruce. If you use GetDate(), SQL Server uses the locale of the SQL Server and if you set an explicitly defined date/time then SQL Server stores that date/time. A simple way to test this is to change the time zone on your PC and run Select getdate() in SSMS against another SQL Server.

    Now if you have users in different time zones using a web application that uses client side scripting to get a date, I don't know what you would end up with.

    Jack Corbett
    Consultant - Straight Path Solutions
    Check out these links on how to get faster and more accurate answers:
    Forum Etiquette: How to post data/code on a forum to get the best help
    Need an Answer? Actually, No ... You Need a Question

  • Yes, I think what was happening is that the Timezone on SQL server in Central Europe was set to GMT but the app was generating local dates.

    Thanks Again

    Buzz

Viewing 4 posts - 1 through 3 (of 3 total)

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