Quantcast
Channel: Sql Server 2008 R2 – MSSQLFUN – Microsoft SQL Server, Database, Replication, SQL Server Agent, Mirroring, Always On, HADR
Viewing all articles
Browse latest Browse all 48

How to Insert datetime with different Timezones

$
0
0

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/)



Viewing all articles
Browse latest Browse all 48

Trending Articles