How to compare and write conditions on active record field "time"
Fpclass(id: integer, name: string, start_time: time) Fpclass.first.start_time # 2000-01-01 01:01:00 UTC
I'm having problem with comparing time field while fetching results as you've seen above its storing all date and time in database even though i mentioned Time field while creating. Does anyone had faced similar kind of problem before ? Can you share me how to approach with time fields in active record, or am i doing something wrong ?
Finally what i need ?
Fpclass.where('start_time>?', Time.now.strftime("%H %M"))
So all the Time instances in Rails include a date with the Time. It will default to January 1st, 2000 as you can see but you can safely ignore that portion of the output.
You should be able to query the database just by doing this and it should ignore the Date portion of the time. Check the development logs for the SQL query to make sure it does.