Quick Reference
This is a quick reference list of SQL Server date functions and how they are used to work with databases.
- SQL – SQL Server CURRENT_TIMESTAMP FunctionThe SQL Server CURRENT_TIMESTAMP() function returns the current date and time as “YYYY-MM-DD HH-MM-SS”.
- SQL – SQL Server DATEADD() FunctionThe SQL Server DATEADD() function adds a time/date interval to a date and then returns the date.
- SQL – SQL Server DATEDIFF() FunctionThe SQL Server DATEDIFF() function returns the difference between two dates.
- SQL – SQL Server DATEFROMPARTS() FunctionThe SQL Server DATEFROMPARTS() function returns a date from the specified parts (year, month, and day values).
- SQL – SQL Server DATENAME() FunctionThe SQL Server DATENAME() function returns a specified part of a date as a string value.
- SQL – SQL Server DATEPART() FunctionThe SQL Server DATEPART() function returns a specified part of a date as an integer value.
- SQL – SQL Server DAY() FunctionThe SQL Server DAY() function returns the day of the month (from 1 to 31) for a specified date.
- SQL – SQL Server GETDATE() FunctionThe SQL Server GETDATE() function returns the current database system date and time, in a “YYYY-MM-DD hh:mm:ss.mmm” format.
- SQL – SQL Server GETUTCDATE() FunctionThe SQL Server GETUTCDATE() function returns the current database system UTC date and time, in a “YYYY-MM-DD hh:mm:ss.mmm” format.
- SQL – SQL Server ISDATE() FunctionThe SQL Server ISDATE() function checks an expression and returns 1 if it is a valid date, and 0 if it is NOT a valid date.
- SQL – SQL Server MONTH() FunctionThe SQL Server MONTH() function returns the month part for a specified date (a number from 1 to 12).
- SQL – SQL Server SYSDATETIME() FunctionThe SQL Server SYSDATETIME() function returns the date and time of the computer where the SQL Server is running.
- SQL – SQL Server YEAR() FunctionThe SQL Server YEAR() function returns the year part for a specified date.
SQL Notes:
- Any work being done to modify the structure of a database or delete tables or the the database itself should only be done after making a recent backup
We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.