Help Center/
GaussDB/
MySQL Compatibility(Centralized)/
M-compatible Mode/
System Functions/
Date and Time Functions
Updated on 2025-04-14 GMT+08:00
Date and Time Functions
The following describes the date and time functions in GaussDB M-compatible mode:
- If a SELECT subquery contains only a time function and the input parameters of the function contain columns in the table, when arithmetic operators (such as +, -, *, /, and the negation operator) are used to calculate the result, the return values of the date and time functions are truncated before the arithmetic operation.
m_db=# CREATE TABLE t1(int_var int); CREATE TABLE m_db=# INSERT INTO t1 VALUES(100); INSERT 0 1 m_db=# SELECT (SELECT (1 * DATE_ADD('2020-10-20', interval int_var microsecond))) AS a FROM t1; -- Truncate is not performed. a ---------------- 20201020000000 (1 row) m_db=# SELECT (1 * (SELECT DATE_ADD('2020-10-20', interval int_var microsecond))) AS a FROM t1; -- Truncation is performed. a ------ 2020 (1 row) m_db=# SELECT 1 * a FROM (SELECT (SELECT 1 * DATE_ADD('2020-10-20', interval int_var microsecond)) AS a FROM t1) AS t2; -- Truncation is not performed. 1 * a ---------------- 20201020000000 (1 row) m_db=# SELECT 1 * a FROM (SELECT (SELECT DATE_ADD('2020-10-20', interval int_var microsecond)) AS a FROM t1) AS t2; -- Truncation is performed. 1 * a ------- 2020 (1 row)
Parent topic: System Functions
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot