Collections:
TIME_TO_SEC() - Converting Time to Seconds
How to convert a time value into seconds using the TIME_TO_SEC() function?
✍: FYIcenter.com
TIME_TO_SEC(time) is a MySQL built-in function that
converts a time value into seconds using the (s + 60*m + 60*60*h) formula.
For example:
SELECT TIME_TO_SEC(NOW(3)), NOW();
-- +---------------------+---------------------+
-- | TIME_TO_SEC(NOW(3)) | NOW() |
-- +---------------------+---------------------+
-- | 75921 | 2023-11-15 21:05:21 |
-- +---------------------+---------------------+
1 row in set (0.00 sec)
SELECT TIME_TO_SEC('21:05:21'), 21+60*05+60*60*21;
-- +-------------------------+-------------------+
-- | TIME_TO_SEC('21:05:21') | 21+60*05+60*60*21 |
-- +-------------------------+-------------------+
-- | 75921 | 75921 |
-- +-------------------------+-------------------+
SELECT TIME_TO_SEC('100:00:00');
-- +--------------------------+
-- | TIME_TO_SEC('100:00:00') |
-- +--------------------------+
-- | 360000 |
-- +--------------------------+
Reference information of the TIME_TO_SEC() function:
TIME_TO_SEC(time): int converts a time value into seconds using the (s + 60*m + 60*60*h) formula. Arguments, return value and availability: time: Required. The time value to be converted. int: Return value. The number of seconds from the given time. Available since MySQL 4.
⇒ TO_DAYS() - Converting Date to Days
⇐ TIME_FORMAT() - Formatting Time
2023-11-17, 1048🔥, 0💬
Popular Posts:
What Are the Underflow and Overflow Behaviors on FLOAT Literals in SQL Server Transact-SQL? If you e...
How To Get the Definition of a Stored Procedure Back in SQL Server Transact-SQL? If you want get the...
What Is a Parameter File in Oracle? A parameter file is a file that contains a list of initializatio...
How To Verify a User name with SQLCMD Tool in SQL Server? The quickest way to verify a user name in ...
How To Format DATETIME Values to Strings with the CONVERT() Function in SQL Server Transact-SQL? SQL...