在PostgreSQL中,我需要一种方法来确定当前时间是否在带有opens_at和closes_at时间戳的特定模型的工作时间内。什么是有效的Postgres方法。
对于Sqlite3,我有:
(opens_at > closes_at AND
(TIME(opens_at) > :now OR :now < TIME(closes_at)))
OR
(closes_at > opens_at AND
(TIME(opens_at) < :now AND TIME(closes_at) > :now))
我忘了说这正在运行,ActiveRecord
所以:now
实际上等于当前的UTC时间。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句