New DateTime function in SQL Server 2008

SQL Server 2008 comes with some new datetime function ,
lets get some overview of it


SYSDATETIME


Provide current date and time in datetime2 datatype



select GETDATE()

Result
2009-03-11 10:21:06.643

select SYSDATETIME()

Result 2009-03-11 10:21:06.6452500

Here we can see difference in Time. Getdate is using datetime datatype and can provide data up to micro second while SYSDATETIME is using datetime2 datatype and can provider result up to 100 nanoseconds.


SYSUTCDATETIME


Provide result in datetime2 datatype

select GETUTCDATE()

Result
2009-03-11 10:33:01.550


select SYSUTCDATETIME()

Result
2009-03-11 10:33:01.5515000

Here we can see difference in Time. GETUTCDATE is using datetime datatype and can provide data up to micro second while SYSUTCDATETIME is using datetime2 datatype and can provider result up to 100 nanoseconds.

SYSDATETIMEOFFSET

SELECT SYSDATETIMEOFFSET()

Result
2009-03-11 16:04:13.2390000 +05:30
Provides current datetime in datetime2 datatype with timezone difference.

No comments:

Post a Comment

Popular Posts