问题
I have a column which is of datetime data type. It contains few entries. So while getting the value from the select statement I want to output with Time zone. Please help me
for example
2007-05-08 12:35:29.1234567 +05:30 (GMT)
回答1:
Cast it to dtaetimeoffset like
select CAST(dt as datetimeoffset) from test
EDIT:
you can then use SWITCHOFFSET to get into the specified timezone. For your example
select switchoffset(CAST(dt as datetimeoffset),'+05:30') from test
Results in 2011-11-24 23:26:30.0600000 +05:30
来源:https://stackoverflow.com/questions/8256892/converting-normal-datetime-to-a-time-zone-in-sql-server-2008