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 7632763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:42:31+00:00 2026-05-31T06:42:31+00:00

I am attempting to find ‘entries’ create today (in my current timezone) using the

  • 0

I am attempting to find ‘entries’ create today (in my current timezone) using the following:

Entry.where("DATE(created_at) = DATE(?) AND email = ?", Time.now, email)

Time.now is giving me the time in the current zone, but the query seems like it is searching against the UTC time of each entry’s created_at column.

Any ideas how I can find entries created today in the server’s timezone?

  • 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-05-31T06:42:33+00:00Added an answer on May 31, 2026 at 6:42 am

    You’re losing track of the timezone information as soon as you call the DATE() function in your SQL. There are two things to keep in mind:

    1. Everything inside the database will be in UTC and everything includes the result of DATE().
    2. A single date (i.e. day) in your local time zone can easily cross two dates in UTC so you need to look at the entire timestamp (on both sides) rather than just the (UTC) date components.

    Something like this should work:

    now = Time.now
    Entry.where('created_at between :start and :end and email = :email',
        :start => now.beginning_of_day,
        :end   => now.end_of_day,
        :email => email
    )
    

    The times should be converted to UTC automatically. You might want to handle the upper bound a little differently; using end_of_day gives you 23:59:59 so there is a little room for something to slip through that you want to capture. You can get around that problem using an explicit half-open interval (rather than the closed interval that SQL’s between uses) like this:

    now = Time.now
    Entry.where('created_at >= :start and created_at < :end and email = :email',
        :start => now.beginning_of_day,
        :end   => now.tomorrow.beginning_of_day,
        :email => email
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to find a binary file in a Linux system using something
I have the following code inside a Form, and am attempting to find a
I am attempting to find the MAC address using pcap for a small project.
I am attempting to find all entries in the 'archive' table that have the
Using reflection, I'm attempting to find the set of types which inherit from a
I am displaying images on my page and then attempting to find the current
For the last few days I have been attempting to find a method to
Okay, so what I'm attempting to do is find out the name of the
When attempting to compile my C# project, I get the following error: 'C:\Documents and
I'm attempting to find the euclidean distance in meters between two points on an

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.