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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:32:29+00:00 2026-06-12T07:32:29+00:00

I want all records that are within the allowed dates. SELECT page_id, page_published_date, page_expired

  • 0

I want all records that are within the allowed dates.

SELECT
  page_id, page_published_date, page_expired 
FROM 
  pages
WHERE
  ([page_published_date] <= getdate() OR [page_published_date] is null)
  AND
  ([csp_expired] <= getdate() OR [page_expired] is null)

Mind that dates can contain null values.

Example table:

page_id, page_published_date, page_expired
1        2012-10-05           null
2        null                 2012-10-01
3        2012-08-01           2012-11-30

In this case the correct record would be 3.

  • 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-12T07:32:31+00:00Added an answer on June 12, 2026 at 7:32 am

    Edited answer, based on choosing #3 as the only result

    SELECT
      page_id, page_published_date, page_expired 
    FROM 
      pages
    WHERE
      -- Publication date BEFORE today (current time)
      ([page_published_date] <= getdate() OR [page_published_date] is null)
      AND
      -- and page has not expired
      (datediff(d,0,getdate()) < [page_expired] OR [page_expired] is null)
    

    Direct translation from subject line

    SELECT
      page_id, page_published_date, page_expired 
    FROM 
      pages
    WHERE
      -- Publication date greater than today
      ([page_published_date] > DateDiff(D,0,getdate()) OR [page_published_date] is null)
      AND
      -- and [Publication date?] less than the expiration date
      ([page_published_date] < [page_expired] OR [page_expired] is null)
    

    Notes:

    1. DateDiff(D,0,getdate()) gives you “today”, i.e. without the time portion
    2. I have a feeling you don’t want to compare [page_expired] against today, since today pre-dates the [page_published_date] given the first condition
    3. Use my pattern of translation to plug in any changes as required, if my interpretation is wrong
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to look for all records within a table that has date column
I want to return all records that were added to the database within the
I want to retrieve all records from one table when there are no matches
I want to display all records from table of current autorized user in my
Table A, columns OrderId, OrderTimeStamp (datetime). I want to SELECT all records for any
I want to get all the records from the one table which contain at
I have a DateTime column. I want to extract all records, lets say, from
I have db with this table (TableToDo): http://goo.gl/NlTEk I want display all records in
i want to update all records in my database(mongodb),I tried to use command below
I want all products that contain images to be listed before products that do

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.