- Related Questions & Answers
- What is the significant difference between MySQL TRUNCATE() and ROUND() function?
- What is the use of MySQL FROM_UNIXTIME() function?
- What is the use of MySQL GET_FORMAT() function?
- What is the use of MySQL LAST_INSERT_ID() function?
- What is the use of MySQL CONCAT_WS() function?
- What is the use of MySQL UNHEX() function?
- What is the use of MySQL SUBSTRING_INDEX() function?
- What is the use of MySQL CHAR() function?
- What is the use of FIND_IN_SET () function in MySQL?
- What is the use of LOCATE() function in MySQL?
- What is the use of MySQL NULLIF() control flow function?
- What is the use of MySQL IFNULL() control flow function?
- What is MySQL TRUNCATE command used for?
- What is the difference between MySQL TRUNCATE and DELETE command?
- What is the use of JavaScript eval function?

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

MySQL **TRUNCATE()** function is used to return the value of X truncated to D number of decimal places. If D is 0, then the decimal point is removed. If D is negative, then D number of values in the integer part of the value is truncated. Its syntax can be as follows −

TRUNCATE(X, D)

Here

- X is a number which is to be truncated.
- D is the number up to which decimal places the number X has to be truncated.

In the example below, it will truncate the given number up to 2 decimal places.

mysql> Select TRUNCATE(10.7336432,2); +-----------------------+ | TRUNCATE(10.736432,2) | +-----------------------+ | 10.73 | +-----------------------+ 1 row in set (0.00 sec)

Advertisements