TRUNCATE(x,d)

Description: Returns the value of x truncated to d decimal places.

Examples:

  • TRUNCATE(2.26,1) returns 2.2.

But beware:

  • TRUNCATE(2.26,2) returns 2.25 because non-integer numbers are normally stored as double precision values.

  • TRUNCATE(2.26,4) returns 2.2599.

See also: ROUND(), FORMAT()

Get Sams Teach Yourself MySQL in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.