Example
Return the current date:
SELECT CURDATE();
Definition and Usage
The CURDATE() function returns the current date.
Note: The date is returned as “YYYY-MM-DD” (string) or as YYYYMMDD (numeric).
Return the current date:
SELECT CURDATE();
The CURDATE() function returns the current date.
Note: The date is returned as “YYYY-MM-DD” (string) or as YYYYMMDD (numeric).
Add 2 seconds to a time and return the datetime:
SELECT ADDTIME("2017-06-15 09:34:21", "2");
The ADDTIME() function adds a time interval to a time/datetime and then returns the time/datetime. Continue reading MySQL ADDTIME Function
Add 10 days to a date and return the date:
SELECT ADDDATE("2017-06-15", INTERVAL 10 DAY);
The ADDDATE() function adds a time/date interval to a date and then returns the date. Continue reading MySQL ADDDATE Function
Return a number truncated to 2 decimal places:
SELECT TRUNCATE(135.375, 2);
The TRUNCATE() function truncates a number to the specified number of decimal places.
Return the tangent of a number:
SELECT TAN(1.75);
The TAN() function returns the tangent of a number. Continue reading MySQL TAN Function
Return the sum of the “Quantity” field in the “OrderDetails” table:
SELECT SUM(Quantity) AS TotalItemsOrdered FROM OrderDetails;
The SUM() function calculates the sum of a set of values.
Note: NULL values are ignored. Continue reading MySQL SUM Function
Return the square root of a number:
SELECT SQRT(64);
The SQRT() function returns the square root of a number. Continue reading MySQL SQRT Function
Return the sine of a number:
SELECT SIN(2);
The SIN() function returns the sine of a number. Continue reading MySQL SIN Function
Return the sign of a number:
SELECT SIGN(255.5);
The SIGN() function returns the sign of a number.
This function will return one of the following:
Round the number to 2 decimal places:
SELECT ROUND(135.375, 2);
The ROUND() function rounds a number to a specified number of decimal places.