from_second

description

syntax

DATETIME FROM_SECOND(BIGINT unix_timestamp) DATETIME FROM_MILLISECOND(BIGINT unix_timestamp) DATETIME FROM_MICROSECOND(BIGINT unix_timestamp)

Converts a timestamp to its DATETIME represent, with argument as an integer and returned as a DATETIME type. Returns NULL if unix_timestamp < 0 or if the function result is greater than 9999-12-31 23:59:59.999999.

example

1. mysql> set time_zone='Asia/Shanghai';

3. mysql> select from_second(-1);
4. +---------------------------+
5. | from_second(-1)           |
6. +---------------------------+
7. | NULL                      |
8. +---------------------------+

10. mysql> select from_millisecond(12345678);
11. +----------------------------+
12. | from_millisecond(12345678) |
13. +----------------------------+
14. | 1970-01-01 11:25:45.678    |
15. +----------------------------+

17. mysql> select from_microsecond(253402271999999999);
18. +--------------------------------------+
19. | from_microsecond(253402271999999999) |
20. +--------------------------------------+
21. | 9999-12-31 23:59:59.999999           |
22. +--------------------------------------+

24. mysql> select from_microsecond(253402272000000000);
25. +--------------------------------------+
26. | from_microsecond(253402272000000000) |
27. +--------------------------------------+
28. | NULL                                 |
29. +--------------------------------------+

keywords

1. FROM_SECOND,FROM,SECOND,MILLISECOND,MICROSECOND