#利用CAST 函数将字符串转为TIMESTAMP类型
SELECT CAST('2018-01-31 15:49:15' AS TIMESTAMP)
#利用EXTRACT函数提取时间戳 用法 EXTRACT(关健字 FROM 日期或时间型字段) 返回的类型为interval类型 可以直接参与运算
SELECT EXTRACT(epoch FROM CAST( '2018-01-31 15:49:15' AS TIMESTAMP))
#查询目标时间与当前时间now()的差值 返回秒
SELECT EXTRACT(epoch FROM CAST( '2018-01-31 15:49:15' AS TIMESTAMP)) - EXTRACT(epoch FROM CAST( now() AS TIMESTAMP))
#返回目标时间与当前时间的绝对值 是否大于20秒
SELECT abs(EXTRACT(epoch FROM CAST( '2018-01-31 15:49:15' AS TIMESTAMP)) - EXTRACT(epoch FROM CAST( now() AS TIMESTAMP))) > 20