Home » CodeProject » How to Insert datetime with different Timezones

How to Insert datetime with different Timezones


In SQL Server 2008, Microsoft has introduced a number of new date and time data types. One of these is the datetimeoffset data type. This data type includes an offset from UTC time as well as the datetime value and ensures that the datetime can be retrieved in UTC or a particular timezone based on this offset. There are also new functions to allow for conversions between different time zones using the new function SWITCHOFFSET().

select

converT(datetime,SWITCHOFFSET(converT(datetimeoffset,getdate()),’+05:30′)) Date_India,

converT(datetime,SWITCHOFFSET(converT(datetimeoffset,getdate()),’+03:30′)) Date_Iran

 

If you liked this post, do like on Facebook at http://www.facebook.com/mssqlfun

Reference : Rohit Garg (http://mssqlfun.com/)

Advertisements

4 Comments

  1. a vitamin says:

    bonjour I’m Sarah I’m such a air head but I still particularly loved your blog

  2. rusty says:

    Thanks for finally writing about >How to Insert datetime with different Timezones @ MSSQLFUN <Liked it!

  3. Anonymous says:

    Fabulous, what a weblog it is! This webpage provides valuable data to us, keep it up.

  4. Rob Pastoor says:

    I think this will not work with Daylight Saving Time…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: