Sunday, March 19, 2017

SQL DATE & TIME Functions

All system date and time values are derived from the operating system of the computer on which the instance of SQL Server is running.

Higher-Precision System Date and Time Functions:

1.   SYSDATETIME

Syntax:                                                                          Return Type:

SYSDATETIME()                                datetime2(7)

It returns the datetime value which has date and time of the computer. The result value does not include the time zone offset.




2.   SYSDATETIMEOFFSET

Syntax:                                                                          Return Type:

SYSDATETIMEOFFSET()                     datetimeoffset(7)

It returns the datetime value which has date and time of the computer. The result value includes the time zone offset.



3.   SYSUTCDATETIME

Syntax:                                                                          Return Type:

SYSUTCDATETIME()                             datetime2(7)

It returns the datetime value which has date and time of the computer. The date and time in result value is returned as UTC time.



Lower-Precision System Date and Time Functions:

1.   CURRENT_TIMESTAMP

Syntax:                                                                          Return Type:

CURRENT_TIMESTAMP                                datetime

It returns the datetime value which has date and time of the computer. The result value does not include the time zone offset.



2.   GETDATE

Syntax:                                                                          Return Type:

GETDATE()                                        datetime

It returns the datetime value which has date and time of the computer. The result value does not include the time zone offset.



3.   GETUTCDATE

Syntax:                                                                          Return Type:

GETUTCDATE()                                     datetime


It returns the datetime value which has date and time of the computer. The date and time in result value is returned as UTC time.



Share This
Previous Post
Next Post

TekGrabs, established in 2017, is in the business of sharing Information. It provides news, articles and photos about the different technologies, inventions in different domains. Provides information on programming and databases.

0 comments: