Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8039067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:27:02+00:00 2026-06-05T03:27:02+00:00

I have a model with an expiration datetime field that I’ve been comparing to

  • 0

I have a model with an expiration datetime field that I’ve been comparing to Time.now in finds.

Now my client wants the model to persist in the view until midnight of it’s expiration day.

So, I think what I need to do is be able to call the end_of_day method on the field as part of the find.

Something like…

Model.where(‘expiration.end_of_day < ?’, Time.now)

That certainly doesn’t work and maybe I’m just going about this all wrong.

This is on Rails 3.2 using Postgres (9.1 I think. It’s on Heroku).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T03:27:05+00:00Added an answer on June 5, 2026 at 3:27 am

    I’m assuming that your expiration column is a timestamp rather than a date, which is where the problem stems from. I think something like the following should work for you:

    Model.where('expiration > ?', Time.now.beginning_of_day)  # All records which expire today or later
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model MyModel that has a field expiration_datetime. Every time a user
I have model Article it has field title with some text that may contain
I have model with ManyToManyField field. I also have ModelForm that uses this model.
I have a djano model: class Expiration(models.Model): UNIT_CHOICES = ( ('M', 'Month'), ('W', 'Week')
I have a Ruby on Rails model that has a column called expiration_date .
I have model Foo which has field bar. The bar field should be unique,
I have model: # encoding: utf-8 class Tag include Mongoid::Document field :name, type: String
I have model with ImageFile field: def upload_course_cover(object, filename): return '/media/courses/%s_%s' % (Course.objects.aggregate(Max('id'))['id__max'] +
I have model People and model Group, People has field of type Group. How
I have model that is a queue of Strings associated with enum types. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.