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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:44:46+00:00 2026-05-11T17:44:46+00:00

I have a MySQL db and inside it a table called ProductMaster with 6

  • 0

I have a MySQL db and inside it a table called ProductMaster with 6 fields “Product_Id,Product_Name,Model,Opening_date,Closing_Date,Status”.
Opening_Date and Closing Date Can accept null values.So some records has values for this field

I have the below query to display records from this table.

"select Product_Id,Product_Name,Model from ProductMaster  where Status=1"

Now I want to change the query to have a filter on the Opening_Date and Closing_Date
if they are not null

Ex : If a Record is having Opening_Date as 05/01/2009 and Closing Date as 05/30/2009
Then i want to check whether today is a date in between these two dates and if Yes ,Returns the records

If both field values are empty, Return Records

Can any one help me to frame the query ? Thanks in advance

  • 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-11T17:44:46+00:00Added an answer on May 11, 2026 at 5:44 pm

    The WHERE part of a query (the “WHERE clause”) is just a long boolean expression. What does this mean? That MySQL just wants it to return either true or false, which it understands as “Yes. Include this row in the results.” or “No. Don’t include this row in the results.”

    If I understand correctly, you want to do two things:

    1. Check if the opening_date and closing_date are null
    2. Check if today is between those two dates.

    And you want #2 to only happen if #1 is true. Which could be expressed like:

    #1 AND #2
    

    Which would be evaluated as false if either #1 or #2 is false.

    That can be translated as:

    1. (opening_date IS NOT NULL) AND (closing_date IS NOT NULL)
    2. NOW() >= opening_date AND NOW <= closing_date

    So if we treat those two like the #1 and #2 in the expression we said we were going to use (#1 AND #2) then we get:

    ((opening_date IS NOT NULL) AND (closing_date IS NOT NULL)) 
    AND (NOW() >= opening_date AND NOW <= closing_date`)
    

    And that’s the WHERE clause you need.

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

Sidebar

Ask A Question

Stats

  • Questions 148k
  • Answers 148k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It's hard to know why you would want to pop… May 12, 2026 at 9:22 am
  • Editorial Team
    Editorial Team added an answer I'm working on a project which uses docbook, and has… May 12, 2026 at 9:22 am
  • Editorial Team
    Editorial Team added an answer MemoryAppender will only "append" to memory and is thus mostly… May 12, 2026 at 9:22 am

Related Questions

I'm trying to use jQuery.post() function to retrieve some data. But i get no
I am using annotations to map a basic collection of Strings to an existing
I have a staging Rails site up that's running on MySQL 5.0.32-Debian. On this
I have two issues both related to (I believe) my SQL Server setup. I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.