- Tags: SQL Server
- Categories: Reference, SQL Reference, SQL Resources
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 Function
The SQL Server CURRENT_TIMESTAMP() function returns the current date and time as “YYYY-MM-DD HH-MM-SS”.
SQL – SQL Server DATEADD() Function
The SQL Server DATEADD() function adds a time/date interval to a date and then returns the date.
SQL – SQL Server DATEDIFF() Function
The SQL Server DATEDIFF() function returns the difference between two dates.
SQL – SQL Server DATEFROMPARTS() Function
The SQL Server DATEFROMPARTS() function returns a date from the specified parts (year, month, and day values).
SQL – SQL Server DATENAME() Function
The SQL Server DATENAME() function returns a specified part of a date as a string value.
SQL – SQL Server DATEPART() Function
The SQL Server DATEPART() function returns a specified part of a date as an integer value.
SQL – SQL Server DAY() Function
The SQL Server DAY() function returns the day of the month (from 1 to 31) for a specified date.
SQL – SQL Server GETDATE() Function
The 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() Function
The 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() Function
The 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() Function
The SQL Server MONTH() function returns the month part for a specified date (a number from 1 to 12).
SQL – SQL Server SYSDATETIME() Function
The SQL Server SYSDATETIME() function returns the date and time of the computer where the SQL Server is running.
SQL – SQL Server YEAR() Function
The SQL Server YEAR() function returns the year part for a specified date.
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.
Why 1SMARTchicken?
See More →
Thanks for your support!
SQL Books
All are affiliate links. Thank you for your support!
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
Feedback
If you see an error on the page or the code itself is incorrect or incomplete, or just plain wrong, please let us know. We’re always learning. NOTE: we do not sell your information and will not send you spam emails.