The following table lists the
most important built-in date functions in SQL Server:
Function
|
Description
|
GETDATE()
|
Returns the current date and time
|
DATEPART()
|
Returns a single part of a date/time
|
DATEADD()
|
Adds or subtracts a specified time
interval from a date
|
DATEDIFF()
|
Returns the time between two dates
|
CONVERT()
|
Displays date/time data in different formats
|
SQL Server comes with the
following data types for storing a date or a date/time value in the database:
§ DATE - format YYYY-MM-DD
§ DATETIME - format: YYYY-MM-DD HH:MI:SS
§ SMALLDATETIME - format: YYYY-MM-DD HH:MI:SS
Comments
Post a Comment