Coffeehouse Thread

3 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

DateTimeOffset help in SQL and or .net

Back to Forum: Coffeehouse
  • User profile image

    trying to use the Datetimeoffset data type in .net and sql server and I have been getting some very strange results.

    anyone at Microsoft who knows how this data type works please chime in!

    it seems like in some cases sql server azure and sql enterprise manager are adjusting data  to my local time zone!

    other times it seems like the data is not adjusted!

    it's making it impossible to use the datatype if we can not have set rules on how it works.


  • User profile image

    Your troubles are likely caused by the context of your question.  I hope you are aware both SQL and .NET have multiple date/time values all of which are different from each other.  When you throw in other differences such as Calendar differences it is a wonder you get results at all.


    The "DateTimeOffset", per MSDN, is relative to 01/01/0001.  Other constructs such as DateTime, or DateTime2, have other date ranges.  (Are you aware that .NET DateTime and SQL DateTime have different min/max values??)

    You need to pay attention to the details of things when things get nitty grittty.  THings such as ticks per hour and so on become important.


    Good luck.

  • User profile image

    My suggestion would be to try to isolate and reproduce until it is repeatable.  It could have to do with time zones, daylight saving time, data types, communication protocols, the server or client computer not being updated, and a host of other things.

    It may also be worth looking into using something that is more well-rounded for handling dates, such as

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.