0

I am trying to do a selection for Outprojects with start date within this week;

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)

This works without problem locally (running postgresql), but on heroku it gives a empty result (even though it should not).

I have tried with .to_time (as above), with .to_date and without anything and DateTime instead of Time. Any suggestions?

hso
  • 345
  • 3
  • 19
  • Perhaps [this](http://stackoverflow.com/a/8468036/724036) will help – zishe Jun 03 '14 at 08:32
  • 2
    You need to add timezone on heroku config. http://blog.pardner.com/2012/08/setting-the-default-time-zone-for-a-heroku-app/ – Sachin R Jun 03 '14 at 08:39

1 Answers1

1

Try this:

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

The default time zone for postgresql is UTC.

manu29.d
  • 1,538
  • 1
  • 11
  • 15