Collections:
TO_SECONDS() - Converting Datetime to seconds
How to convert a datetime value into seconds since year 0 using the TO_SECONDS() function?
✍: FYIcenter.com
TO_SECONDS(datetime) is a MySQL built-in function that
converts a datetime value into seconds since year 0.
For example:
SELECT TO_SECONDS('1995-05-01'), TO_SECONDS(950501);
-- +--------------------------+--------------------+
-- | TO_SECONDS('1995-05-01') | TO_SECONDS(950501) |
-- +--------------------------+--------------------+
-- | 62966505600 | 62966505600 |
-- +--------------------------+--------------------+
SELECT TO_SECONDS(NOW()), NOW();
-- +-------------------+---------------------+
-- | TO_SECONDS(NOW()) | NOW() |
-- +-------------------+---------------------+
-- | 63867305526 | 2023-11-15 22:12:06 |
-- +-------------------+---------------------+
Reference information of the TO_SECONDS() function:
TO_SECONDS(datetime): int Given a date or datetime expr, returns the number of seconds since the year 0. If expr is not a valid date or datetime value, returns NULL. Arguments, return value and availability: datetime: Required. The datetime value to be converted. int: Return value. The number of seconds since year 0. Available since MySQL 4.
Related MySQL functions:
⇒ UNIX_TIMESTAMP() - Calculating Unix Timestamp
⇐ TO_DAYS() - Converting Date to Days
2023-11-17, 1253🔥, 0💬
Popular Posts:
How To Use GO Command in "sqlcmd" in SQL Server? "sqlcmd" is a command line client application to ru...
Can Date and Time Values Be Converted into Integers in SQL Server Transact-SQL? Can date and time va...
How To Connect to a MySQL Server with a Port Number in MySQL? If you want to connect a MySQL server ...
How To Concatenate Two Binary Strings Together in SQL Server Transact-SQL? SQL Server 2005 allows to...
How Fixed Length Strings Are Truncated and Padded in SQL Server Transact-SQL? When the length of the...