1

I want to extract the exchange rates from today(ie. the exchange rates have a time field of type DateTime and from this I want to extract the day). I want to do something like this:

ExchangeRates.where("time.day == ?", pred.time)

Is something of the kind possible?

bsky
  • 19,326
  • 49
  • 155
  • 270

1 Answers1

1

Your database doesn't have a DateTime object in it that works like the Rails DateTime object. In order to query you'll have to send it something it understands, like a BETWEEN clause. You could do this:

ExchangeRates.where(time: pred.time.beginning_of_day..pred.time.end_of_day)

I'm assuming pred is a DateTime object

Mario
  • 1,349
  • 11
  • 16