TO_SECONDS(expr)
Returns the number of seconds from year 0 till expr
, or NULL if expr
is not a valid date or datetime.
SELECT TO_SECONDS('2013-06-13'); +--------------------------+ | TO_SECONDS('2013-06-13') | +--------------------------+ | 63538300800 | +--------------------------+ SELECT TO_SECONDS('2013-06-13 21:45:13'); +-----------------------------------+ | TO_SECONDS('2013-06-13 21:45:13') | +-----------------------------------+ | 63538379113 | +-----------------------------------+ SELECT TO_SECONDS(NOW()); +-------------------+ | TO_SECONDS(NOW()) | +-------------------+ | 63543530875 | +-------------------+ SELECT TO_SECONDS(20130513); +----------------------+ | TO_SECONDS(20130513) | +----------------------+ | 63535622400 | +----------------------+ 1 row in set (0.00 sec) SELECT TO_SECONDS(130513); +--------------------+ | TO_SECONDS(130513) | +--------------------+ | 63535622400 | +--------------------+
© 2019 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/to_seconds/