三大数据库时间戳相减得分钟\秒数

sqlserver时间戳:

日期转时间戳:SELECT DATEDIFF(S,'2019-05-10 09:49:59.100', GETDATE());
日期转时间戳:SELECT DATEDIFF(S,'2019-05-12 10:49:59.900', GETDATE());

相减分钟:SELECT (DATEDIFF(S,'2019-05-10 09:49:59.100', GETDATE())-DATEDIFF(S,'2019-05-12 10:49:59.900', GETDATE()))/60;

相减秒数:SELECT (DATEDIFF(S,'2019-05-10 09:49:59.100', GETDATE())-DATEDIFF(S,'2019-05-12 10:49:59.900', GETDATE()));

 

myql时间戳相减:

相减分钟:select timestampdiff(SECOND,'2015-05-04 12:00','2015-05-04 12:01:30')/60;

相减秒数:select timestampdiff(SECOND,'2015-05-04 12:00','2015-05-04 12:01:30');

 

postgresql时间戳相减:

相减分钟:SELECT (EXTRACT(epoch FROM NOW())-EXTRACT(epoch FROM CAST('2017-12-06 00:17:10' AS TIMESTAMP)))/60;

相减秒数:SELECT EXTRACT(epoch FROM NOW())-EXTRACT(epoch FROM CAST('2017-12-06 00:17:10' AS TIMESTAMP));

posted @ 2019-07-31 11:15  优雅de宇  阅读(4425)  评论(0编辑  收藏  举报