Collections:
TIMESTAMP() - Adding Time to Timestamp
How to add a time value to a datetime value using the TIMESTAMP() function?
✍: FYIcenter.com
TIMESTAMP(datetime, time) is a MySQL built-in function that
adds a time value to a datetime value.
For example:
SELECT TIMESTAMP('2023-12-31 12:00:00', '12:00:00');
-- +---------------------------------------------+
-- | TIMESTAMP('2023-12-31 12:00:00','12:00:00') |
-- +---------------------------------------------+
-- | 2024-01-01 00:00:00 |
-- +---------------------------------------------+
SELECT TIMESTAMP('2023-12-31 12:00:00', '-48:00:00');
-- +-----------------------------------------------+
-- | TIMESTAMP('2023-12-31 12:00:00', '-48:00:00') |
-- +-----------------------------------------------+
-- | 2023-12-29 12:00:00 |
-- +-----------------------------------------------+
Reference information of the TIMESTAMP() function:
TIMESTAMP(datetime, time): dt Adds the second argument as a time value to the first argument and returns the result as a datetime value. Arguments, return value and availability: datetime: Required. The timestamp to be subtracted from. time: Optional. Default is '00:00:00'. The time value to be subtracted. dt: Return value. The updated timestamp. Available since MySQL 4.
Related MySQL functions:
⇒ TIMESTAMPADD() - Incrementing Timestamp
⇐ TIMEDIFF() - Difference of Two Timestamps
2023-11-17, 1116🔥, 0💬
Popular Posts:
Can You Drop an Index Associated with a Unique or Primary Key Constraint in Oracle? You can not dele...
What Happens If the UPDATE Subquery Returns Multiple Rows in SQL Server? If a subquery is used in a ...
How To Start MySQL Server in MySQL? If you want to start the MySQL server, you can run the "mysqld" ...
Where to find answers to frequently asked questions on Downloading and Installing SQL Server 2005 Ex...
How To End a Stored Procedure Properly in SQL Server Transact-SQL? Where the end of the "CREATE PROC...