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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:42:02+00:00 2026-06-13T00:42:02+00:00

I am trying to use use a few conditions to select records based on

  • 0

I am trying to use use a few conditions to select records based on start and end dates. Basically I want anything without an end date or that starts in the given period or ends in the same given period. Any help or direction on how this might be accomplished would be very appreciated. I’m including the WHERE part of the query below and the parameter binding but can include more if needed.

$periodsCxn->bindParam(':PositionID',$PositionID);
$periodsCxn->bindParam(':Start',$firstPayPeriod);
$periodsCxn->bindParam(':End',$lastPayPeriod);
$periodsCxn->bindParam(':Start2',$firstPayPeriod);
$periodsCxn->bindParam(':End2',$lastPayPeriod);

WHERE
        POSITION_PERIOD.PositionID = :PositionID AND
        (
            (
                POSITION_PERIOD.EndDate = '1900-01-01'
                OR
                POSITION_PERIOD.EndDate IS NULL
            )
            OR
            (
                POSITION_PERIOD.StartDate BETWEEN :Start AND :End
                OR
                POSITION_PERIOD.EndDate BETWEEN :Start2 AND :End2
            )
        )       
  • 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-13T00:42:05+00:00Added an answer on June 13, 2026 at 12:42 am

    It surprises me that you would want any record without an end date, but be comparing start dates in other cases.

    Typically, with such data, you want to know if a given period overlaps another period, even when that period might have no end date. The logic for the overlap is:

    where POSITION_PERIOD.PositionID = :PositionID AND
          POSITION_PERIOD.StartDate <= :End and
          (POSITION_PERIOD.EndDate >= :Start or
           POSITION_PERIOD.EndDate = '1900-01-01' or
           POSITION_PERIOD.EndDate IS NULL
          )
    

    This assumes that the variables have valid dates.

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

Sidebar

Related Questions

I'm trying to use LINQ to SQL to select a few specific columns from
I'm trying to use autocomplete based on few sources. E.g. search in facebook graph
I am trying to use jQuery's bounce effect on a few images. When I
I am trying to use a for-if loop to run through a few CheckBoxList
i'm trying to use json_decode to combine a few json objects and then re-encode
I've been trying to use Python for a few sample programming competition questions, but
I'm trying to use Python to concatenate a few javascript files together before minifying
I am trying to use following code to perform few animations -(void) performSlidingfromX:(int) xx
I'm trying to use a TableLayoutPanel to align a few controls on a form
I'm having a few problems with the NSScrollView I'm trying to use and could

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.