Collections:
SUBTIME() - Subtracting Time
How to subtract a time interval from a given date or time value using the SUBTIME() function?
✍: FYIcenter.com
SUBTIME(time, expr) is a MySQL built-in function that
subtracts a time interval from a given date or time value.
For example:
SELECT SUBTIME('2022-03-01 23:59:59.999999','1 1:1:1.000002');
-- +--------------------------------------------------------+
-- | SUBTIME('2022-03-01 23:59:59.999999','1 1:1:1.000002') |
-- +--------------------------------------------------------+
-- | 2022-02-28 22:58:58.999997 |
-- +--------------------------------------------------------+
SELECT SUBTIME('01:00:00.999999', '02:00:00.999998');
-- +-----------------------------------------------+
-- | SUBTIME('01:00:00.999999', '02:00:00.999998') |
-- +-----------------------------------------------+
-- | -00:59:59.999999 |
-- +-----------------------------------------------+
Reference information of the SUBTIME() function:
SUBTIME(expr1, expr2): modtime Subtracts expr2 from expr1 and returns the result. expr1 is a time or datetime expression, and expr2 is a time expression. Arguments, return value and availability: expr1: Required. The starting time to be subtracted from. expr2: Required. The time interval to be subtracted. modtime: Return value. The updated time. Available since MySQL 4.0.
Related MySQL functions:
⇒ SYSDATE() - Current Timestamp
⇐ SUBDATE() - Synonym for DATE_SUB()
2023-11-17, 1070🔥, 0💬
Popular Posts:
What is sqlservr.exe - Process - SQL Server (SQLEX?PRESS) in SQL Server? Process sqlservr.exe is the...
Where to find answers to frequently asked questions on INSERT, UPDATE and DELETE Statements in MySQL...
How To Use DATEADD() Function in SQL Server Transact-SQL? DATEADD() is a very useful function for ma...
How To List All Login Names on the Server in SQL Server? If you want to see a list of all login name...
How To Convert Binary Strings into Integers in SQL Server Transact-SQL? Binary strings and integers ...