Date Check

  • Hi all,

    I have two tables in my table startDate and Enddate. I want to check whether a given date is avalible in between the startDate and

    Enddate.How can I. some times the startDate or Enddate may be null. How can I ?

    Thanks

    Dana

  • Are there referenced columns in these two tables?

  • Select

    *

    from

    MyTable

    where

    @MyDate > StartDate and @MyDate < EndDate

  • Just curious... I can see where a NULL end date could be interpreted as 31 Dec 9999, but what does a NULL start date indicate other than something hasn't started? And, do you have the possibility of (incorrectly, I believe) having a NULL start date and a non-null end date?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

  • Jeff Moden (1/18/2008)


    ...but what does a NULL start date indicate other than something hasn't started?...

    Depends on how you use NULL. It could mean does not exist, does not apply, or do not know.

    It could be for an application that you can just not know a value, even though it logically has to exist.

    You might ask a customer for information that they refuse to give, but you still want their business.

    Sales Rep: "May I have your birthday, please?"

    Customer: "No."

    That has always been one of the criticisms of the use of NULL; there can be multiple reasons why it is NULL. If it is important, then the application should capture why it is NULL.

  • Heh... yep, I knew that Michael... sorry I didn't state things clearly... I wanted to know the condition of the OPs data.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply