Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DateTimeOffset.Now in T-SQL

I'm executing a INSERT to a sql 2008 db. How do I specify in T-SQL to insert NOW in a DATETIMEOFFSET column? GETDATE()?

like image 887
Robert Avatar asked Jun 26 '09 10:06

Robert


People also ask

What is datetimeoffset in SQL Server?

On Transact SQL language the datetimeoffset is part of date and time data types and define a date that is combined with a time of a day that has time zone awareness. Datetimeoffset syntax: Property.

What is sysdatetimeoffset in SQL Server?

SYSDATETIMEOFFSET() Examples in SQL Server (T-SQL) In SQL Server, the transact-sql SYSDATETIMEOFFSET() function returns a datetimeoffset(7) value that contains the date and time of the computer on which the instance of SQL Server is running. This value includes the time zone offset.

Can I store dates with a time zone offset in SQL Server?

The idea of storing dates and times with a time zone offset is relatively new to SQL Server and is often underutilized in applications. One can hope that it becomes more commonplace as more SQL developers learn about it and the ease in which it can be implemented.

What is the datetimeoffset data type in Python?

The datetimeoffset data type includes the date and time with a time zone offset. It also has a fractional seconds part between 0 and 7 (this depends on how many fractional seconds are assigned to it). This is done by using the datetimeoffset (n) syntax. If you don’t specify this, it will use 7 (the default).


1 Answers

Maybe.

This would give you the local time of the server where SQL is installed.

Do you want to store timezone etc too? If so, SYSDATETIMEOFFSET() may be better

like image 98
gbn Avatar answered Sep 18 '22 22:09

gbn