如何在Sqlite中的列中减去给定时间内的秒数

时间:2017-06-26 22:42:53

标签: sqlite

在sqlite表中有两列名为time_seconds和date_seconds现在使用此列我需要减去秒并获取时间 前

   date_seconds              time_seconds   
2017-06-26 17:36:41.0              7               
2017-06-26 17:36:41.0              18              
2017-06-26 17:36:41.0              126             
2017-06-26 17:36:41.0              1200  

new_tim = date_seconds - time_seconds

new_tim 
2017-06-26 17:36:34.0   
2017-06-26 17:36:23.0   
2017-06-26 17:34:35.0   
2017-06-26 17:16:41.0 

1 个答案:

答案 0 :(得分:1)

尝试:

SELECT datetime(strftime('%s', substr(date_seconds, 1, 19))-time_seconds, 'unixepoch') FROM X;