Make a note of the search method when the date and time are stored in the DB as character strings.
start_datetime = '2020/12/22 23:35'
scope = Post.all
start_date, start_time = start_datetime.split(' ')
#Extract after the corresponding date
scope = scope.where('start_date >= ?', start_date)
# start_Remove non-applicable times when dates are equal
scope = scope.where.not('start_date = ? AND start_time < ?', start_date, start_time)
Recommended Posts