DATETIME_TRUNC()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Returns a DATETIME
with the fractional seconds truncated to the requested number of decimal places.
USAGE
DATETIME_TRUNC(timestamp, count)
Argument Name | Description |
---|---|
| The |
| The number of digits desired after the decimal point |
DETAILS
DATETIME_TRUNC()
is a mathematical function that returns the timestamp
truncated to count
decimal places.
Note that truncated digits are replaced with trailing zeros.
A NULL
is returned if either argument is NULL
or the requested number of digits is not in the range 0-6.
EXAMPLES
SELECT DATETIME_TRUNC('2022-04-01 12:34:56.123456', 2);
+-------------------------------------------------+
| DATETIME_TRUNC('2022-04-01 12:34:56.123456', 2) |
+-------------------------------------------------+
| 2022-04-01 12:34:56.120000 |
+-------------------------------------------------+