mysql - rails email sending code needs days + 2 for tomorrow, why is that? -


i have loop select 'libraryswaps' tomorrow.

this works, not when set days_ahead default 1 (it returns records todays date).

why need add 2 date day 1 day in future? doing 11am est not time zone issue , utc both being same day... thought maybe 'cos 1 side has time component , other doesn't nope, i'm using date() sql , date + 1.days ruby. may switch (one date minus other date) , @ result.

thanks!

returns tomorrows (uses 2):   def self.find_future_swaps(days_ahead=2)     @upcoming_swaps = libraryswap.all(:conditions => ['date(suggested_date) = ?',date.today + days_ahead.day ])   end  returns todays (uses 1):   def self.find_future_swaps(days_ahead=1)     @upcoming_swaps = libraryswap.all(:conditions => ['date(suggested_date) = ?',date.today + days_ahead.day ])   end 

mysql storing suggested_date field in utc. entry 10pm on 4/29 stored 3am on 4/30 (assuming you're in eastern timezone).

you can add offset times you're searching for:

    @upcoming_swaps = libraryswap.all(:conditions => ['date(convert_tz(suggested_date,'+00:00','-05:00')) = ?',date.today + days_ahead.day ]) 

Comments