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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:19:19+00:00 2026-05-28T03:19:19+00:00

I have the date when an article was created in a DB table. I

  • 0

I have the date when an article was created in a DB table. I have articles since the August until today.

I tried to create a SQL query, in ActiveRecord, to get the articles that were created today.

For example, today is the 14th of January and I tried to get those articles that were created on the 14th of August, 14th of September until today.

I tried something like this:

today = Date.today
day = today.strftime('%d')
day_next = (today + 1.day).strftime('%d')

Article.where('created_at >= ? AND created_at <= ?', day, day_next) #day = 14, day_next = 15

But this doesn’t return the right statement, because articles were released on the 14th of December and the 14th of October. This query returns me nothing.

  • 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-28T03:19:19+00:00Added an answer on May 28, 2026 at 3:19 am

    You’re overthinking this. Assuming created_at is a normal datetime/timestamp field you should just convert created_at to its day using DAY() and then compare it directly to a normal Ruby Date object.

    day = Date.today
    
    Article.where 'DAY( created_at ) = DAY( ? )', day
    
    # or just...
    
    Article.where 'DAY( created_at ) = DAY( CURRENT_DATE() )'
    

    (Misread your question originally; answer updated.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following database table created thus: CREATE TABLE AUCTIONS ( ARTICLE_NO VARCHAR(20),
I have a date and time column in my mysql table called start_date and
I have a date time property in a linq to sql model and I
I have this script to output everything from table called Articles. If I load
Please consider following schema CREATE table articles ( id Int UNSIGNED NOT NULL AUTO_INCREMENT,
I've written PL/SQL code to denormalize a table into a much-easer-to-query form. The code
I have the following table in MySQL... CREATE TABLE `visits` ( `id` int(10) unsigned
I have created a linked-server definition according to the article at : http://www.ideaexcursion.com/2009/01/05/connecting-to-oracle-from-sql-server/ My
Suppose you have a table like: create table user_news ( user_id int unsigned not
OK so I have read a whole bunch of articles suggesting table-value functions and

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.