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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:50:59+00:00 2026-05-26T09:50:59+00:00

I build my simple blog system and every article in the system has two

  • 0

I build my simple blog system and every article in the system has two inputs for setting the the, from that the article will be visible for the visitors and the second input is for the date, till that will be visited.

For example, if I will set to this inputs the values

2011-10-25 and 2011-10-28, so that’s mean, the article will be visible 3 days. If I wanted to have an article still visible, so I would like to have in inputs the values 0000-00-00.

But now I think how to make an sql query – I try something like:

Article.where('from_date <= ? AND to_date >= ?', Func.today, Func.today)

This works me if I have set a date, from that and till that I want to have an article visible. But if I will set that I want to have an article visible everytime (0000-00-00), so this query doesn’t works…

I would like to ask you about the hint, how to update the sql query above for it…

Thanks in advance,

Manny

  • 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-26T09:51:00+00:00Added an answer on May 26, 2026 at 9:51 am

    Instead of setting the date fields to all zeros, set them to nil and look for null values in the query.

    Article.where('(from_date IS NULL OR from_date <= ?) AND (to_date IS NULL OR to_date >= ?)', Func.today, Func.today)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to build a simple method that creates an XML file from
i want to do test and build simple debugger GUI in c++ that debugging
How to build a simple recommendation system? I have seen some algorithms but it
I want to build a simple application with the MVVM pattern. This application will
Thanks in advance! I have a simple mysql and php blog that I built
I am going to build a very simple blogging system in PHP. It should
I'm trying to build a very, very simple micro-webapp which I suspect will be
I want to build a simple blog which contains: A home page with blogs
I want to build a blog with only HTML, meaning that no database, no
I have built a very simple blog application using Ruby on Rails. New to

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.