Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server 2008 GET DATETIMEOFFSET according to machine settings

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

SELECT CAST(GETDATE() AS DATETIMEOFFSET);

This gives me the result as below:

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

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

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

Here is my machine's Date and Time Settings:

enter image description here

The same thing happens while I am inserting a value:

DECLARE @foo AS TABLE(
    fooDate DATETIMEOFFSET
);

INSERT @foo VALUES(GETDATE());

SELECT * FROM @foo;

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

What am I missing here?

like image 431
tugberk Avatar asked Dec 26 '11 08:12

tugberk


1 Answers

Try this

SELECT SYSDATETIMEOFFSET();

GETDATE() function has no any timezone information

like image 73
Oleg Dok Avatar answered Nov 15 '22 22:11

Oleg Dok