拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...
Then there is no way to use TIMESTAMPYou can consider using the DATETIMEtype
DATE range '1000-01-01' to '9999-12-31'
DATETIME'1000-01-01 00:00:00' to '9999-12-31 23:59:59'
TIMESTAMP '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC
-- N秒前 SELECT TIMESTAMPADD(SECOND,-3600,'1970-01-01 00:00:01') -- >> 1969-12-31 23:00:01 -- 2天前 SELECT TIMESTAMPADD(DAY,-2,'1970-01-01 00:00:01') -- >> 1969-12-30 00:00:01 # FRAC_SECOND。表示间隔是毫秒 # SECOND。秒 # MINUTE。分钟 # HOUR。小时 # DAY。天 # WEEK。星期 # MONTH。月 # QUARTER。季度 # YEAR。年
Make sure the negative number you save is relative to 1970-01-01 00:00:01, there is no problem in this calculation
select TIMESTAMPADD(FRAC_SECOND, table.create_time, '1970-01-01 00:00:01') as `create_time` from table
Then there is no way to use TIMESTAMP
You can consider using the DATETIMEtype
DATE range '1000-01-01' to '9999-12-31'
DATETIME'1000-01-01 00:00:00' to '9999-12-31 23:59:59'
TIMESTAMP '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC
Make sure the negative number you save is relative to 1970-01-01 00:00:01, there is no problem in this calculation