The SQL-Date-Functions tag is for questions related to database SQL functions that handle date and time information.
For database data stored as date or timestamp data types, SQL has several date functions to perform various calculations. For determining the number of days between two dates, the date values can simply be subtracted.
MS SQL Server specifics
Formatting and Converting
For converting text strings into proper date/time values there are functions such as to_date('13-Dec 2008 13.05.33', 'dd-Mon YYYY hh24.mi.ss')
and functions for formatting a date into a text string, such as to_char(hire_date, 'WW-YYYY')
which would return the week number and year for the hire_date.
Calculations
Other functions are used for calendaring information, such as last_day(date)
which returns the last day of the month for the specified date.
See Also
The tag sqldatetime is used for questions regarding the various types of date/time data types such as DATE
and TIMESTAMP
.