MySQL CURDATE Function

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).

Continue reading MySQL CURDATE Function

MySQL ADDTIME Function

Example

Add 2 seconds to a time and return the datetime:

SELECT ADDTIME("2017-06-15 09:34:21", "2");

Definition and Usage

The ADDTIME() function adds a time interval to a time/datetime and then returns the time/datetime. Continue reading MySQL ADDTIME Function

MySQL ADDDATE Function

Example

Add 10 days to a date and return the date:

SELECT ADDDATE("2017-06-15", INTERVAL 10 DAY);

Definition and Usage

The ADDDATE() function adds a time/date interval to a date and then returns the date. Continue reading MySQL ADDDATE Function

MySQL TRUNCATE Function

Example

Return a number truncated to 2 decimal places:

SELECT TRUNCATE(135.375, 2);

Definition and Usage

The TRUNCATE() function truncates a number to the specified number of decimal places.

Continue reading MySQL TRUNCATE Function

MySQL SUM Function

Example

Return the sum of the “Quantity” field in the “OrderDetails” table:

SELECT SUM(Quantity) AS TotalItemsOrdered FROM OrderDetails;

Definition and Usage

The SUM() function calculates the sum of a set of values.

Note: NULL values are ignored. Continue reading MySQL SUM Function

MySQL SQRT Function

Example

Return the square root of a number:

SELECT SQRT(64);

Definition and Usage

The SQRT() function returns the square root of a number. Continue reading MySQL SQRT Function

MySQL SIN Function

Example

Return the sine of a number:

SELECT SIN(2);

Definition and Usage

The SIN() function returns the sine of a number. Continue reading MySQL SIN Function

MySQL ROUND Function

Example

Round the number to 2 decimal places:

SELECT ROUND(135.375, 2);

Definition and Usage

The ROUND() function rounds a number to a specified number of decimal places.

Continue reading MySQL ROUND Function