【问题标题】:Comparing dates on heroku pgsql比较heroku pgsql上的日期
【发布时间】:2014-06-03 08:29:13
【问题描述】:

我正在尝试选择开始日期在本周内的 Outprojects;

Outproject.where('start_at > ? and start_at < ?', Time.now.at_beginning_of_week.to_time,(Time.now.at_beginning_of_week + 5.days).to_time)

这在本地工作没有问题(运行 postgresql),但在 heroku 上它给出了一个空结果(即使它不应该)。

我尝试过使用 .to_time(如上),使用 .to_date 并且没有任何内容,使用 DateTime 而不是 Time。有什么建议吗?

【问题讨论】:

标签: ruby-on-rails ruby postgresql heroku ruby-on-rails-4


【解决方案1】:

试试这个:

Outproject.where('start_at >= ? and start_at <= ?', DateTime.now.beginning_of_week.utc,(DateTime.now.beginning_of_week + 5.days).utc)

default time zone for postgresql 是 UTC。

【讨论】:

    猜你喜欢
    • 2012-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-31
    • 2018-11-24
    • 2018-12-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多