LAST_DAY
takes date and returns the last date of the month.
In the example the result is 28
because the year is not leap yearSELECT
LAST_DAY('2021-02-15')
MAKETIME
takes three parameters as hour, minute and time and returns formatted time like: 18:15:19
SELECT
MAKETIME(18, 15, 19)
DATEDIFF
Calculates the number of days between the two parameters.
In this example the function returns 12
which is the number of days between the datesSELECT
DATEDIFF('2021-03-25', '2021-03-13')
The function returns negative number
if the second date is greater than the first one.
In the example the result will be -12
SELECT
DATEDIFF('2021-03-13', '2021-03-25')
SUBDATE
subtracts some amount of time from the specified dateSELECT
SUBDATE('2021-03-25', INTERVAL 30 DAY)
ADDDATE
adds some amount of time to the specified dateSELECT
ADDDATE('2021-03-25', INTERVAL 8 DAY)
SELECT
SYSDATE()
We can pass parameter precision
to the function that indicates milliseconds and microseconds:SELECT
SYSDATE(6)
Maximum precision
is 6, if we pass more than the supported number, we will get an errorSELECT
SYSDATE(7)
After running the query, the following error will be generated:#1426 - Too big precision 7 specified for 'sysdate'. Maximum is 6