回答

收藏

从Now()到Postgresql中的Current_timestamp

技术问答 技术问答 161 人阅读 | 0 人回复 | 2023-09-14

在MySQL中,我能做到这一点:" Y* C9 B: V4 ~$ `/ X6 c' c: e
SELECT *FROM tableWHERE auth_user.lastactivity > NOW() - 100现在在PostgreSQL我正在使用这个查询
+ H+ P/ f6 c$ r) C# ZSELECT *FROM tableWHERE auth_user.lastactivity > CURRENT_TIMESTAMP - 100但我犯了这个错误:1 w3 b5 x( q' ?* H: _
operator does not exist: timestamp with time zone - integer我该怎么解决?
6 N. |2 Y% L; X( T; Q: g                                                                * M$ b# O2 m4 M$ Z. P2 I4 {
    解决方案:                                                               
) E& P7 ]) |+ t, b2 g: N                                                                使用间隔而不是整数:$ L4 |1 h# J3 T6 Z% P  R
SELECT *FROM tableWHERE auth_user.lastactivity > CURRENT_TIMESTAMP - INTERVAL '100 days'
分享到:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则