SelectDB Cloud
SQL 手册
SQL 函数
日期函数
SECOND_TIMESTAMP

second_timestamp

description

Syntax

BIGINT SECOND_TIMESTAMP(DATETIME date) BIGINT MILLISECOND_TIMESTAMP(DATETIME date) BIGINT MICROSECOND_TIMESTAMP(DATETIME date)

将DATETIME类型转换成对应的时间戳

传入的是DATETIME类型,返回的是整型

example

mysql> select from_millisecond(89417891234789),millisecond_timestamp(from_millisecond(89417891234789));
+----------------------------------+---------------------------------------------------------+
| from_millisecond(89417891234789) | millisecond_timestamp(from_millisecond(89417891234789)) |
+----------------------------------+---------------------------------------------------------+
| 4803-07-17 15:07:14.789          |                                          89417891234789 |
+----------------------------------+---------------------------------------------------------+

mysql> select from_second(89417891234),second_timestamp(from_second(89417891234));
+--------------------------+--------------------------------------------+
| from_second(89417891234) | second_timestamp(from_second(89417891234)) |
+--------------------------+--------------------------------------------+
| 4803-07-17 15:07:14      |                                89417891234 |
+--------------------------+--------------------------------------------+

mysql> select from_microsecond(89417891234),microsecond_timestamp(from_microsecond(89417891234));
+-------------------------------+------------------------------------------------------+
| from_microsecond(89417891234) | microsecond_timestamp(from_microsecond(89417891234)) |
+-------------------------------+------------------------------------------------------+
| 1970-01-02 08:50:17.891234    |                                          89417891234 |
+-------------------------------+------------------------------------------------------+

keywords

SECOND_TIMESTAMP
© 2023 北京飞轮数据科技有限公司 京ICP备2022004029号 | Apache、Apache Doris 以及相关开源项目名称均为 Apache 基金会商标