SQL date functions allow you to manipulate date and time data effectively. You can use the date functions for various operations such as adding days to a date, calculating the difference between two dates, or getting parts of a date.
Name | Description |
CURRENT_DATE | Return the current date |
CURRENT_TIME | Return the current time |
CURRENT_TIMESTAMP | Return the current date and time |
Convert date to string | Use the CAST() or TO_CHAR() function to convert a date to a string |
Convert string to date | Use the CAST() or TO_DATE() function to convert a string to a date based on a specified format |
DATEADD | Add an interval to a date |
DATEDIFF | Find the difference between two dates |
DATEPART | Extract a part of a date such as a year, month, and day from a given date |
Extract Year from Date | Extract the year from a date |
Extract Month from Date | Extract the month from a date |
Extract Day from Date | Extract the day of the month from a date |