SQL Server 2008 GET DATETIMEOFFSET according to machine settings

In SQL Server 2008 R2, I have the following T-SQL code:

SELECT CAST(GETDATE() AS DATETIMEOFFSET); 

This gives me the result as shown below:

2011-12-26 10: 21: 13.7970000 +00: 00

But I wanted to be the result. It should be like this:

2011-12-26 10: 21: 13.7970000 +02: 00

Here are my date and time settings:

enter image description here

The same thing happens when I insert a value:

 DECLARE @foo AS TABLE( fooDate DATETIMEOFFSET ); INSERT @foo VALUES(GETDATE()); SELECT * FROM @foo; 

This gives me the same wrong result (at least the wrong one for my needs).

What am I missing here?

+7
source share
1 answer

try it

 SELECT SYSDATETIMEOFFSET(); 

GETDATE() function has no time zone information

+16
source

All Articles