Professional Web Applications Themes

HowTo Select an ID where a "Date" is between startDate and endDate? - Microsoft SQL / MS SQL Server

Hello, I have this table ID startDate endDate ------------------------------- 1 04/01/2003 07/30/2003 2 08/01/2003 09/30/2003 3 02/11/2004 04/15/2004 How can I get the ID when I give in my SELECT a DATE to find out if this DATE is between startDate and endDate? Example: Input date in my Select: 08/03/2003 Output: ID=2 Input date in my Select: 08/03/2011 Output: NULL How do I have to make my Select? Many thanks in advance for any help!! Andreas...

  1. #1

    Default HowTo Select an ID where a "Date" is between startDate and endDate?

    Hello,

    I have this table

    ID startDate endDate
    -------------------------------
    1 04/01/2003 07/30/2003
    2 08/01/2003 09/30/2003
    3 02/11/2004 04/15/2004

    How can I get the ID when I give in my SELECT a DATE to find out if this
    DATE is between
    startDate and endDate?

    Example:
    Input date in my Select: 08/03/2003
    Output: ID=2

    Input date in my Select: 08/03/2011
    Output: NULL

    How do I have to make my Select?


    Many thanks in advance for any help!!
    Andreas


    Andreas Klemt Guest

  2. #2

    Default Re: HowTo Select an ID where a "Date" is between startDate and endDate?

    select id from MYTABLE where '08/03/2003' >startDateate and '08/03/2003'<
    endDate


    "Andreas Klemt" <aklemt68hotmail.com> wrote in message
    news:%23B6LsDoQDHA.2636TK2MSFTNGP10.phx.gbl...
    > Hello,
    >
    > I have this table
    >
    > ID startDate endDate
    > -------------------------------
    > 1 04/01/2003 07/30/2003
    > 2 08/01/2003 09/30/2003
    > 3 02/11/2004 04/15/2004
    >
    > How can I get the ID when I give in my SELECT a DATE to find out if this
    > DATE is between
    > startDate and endDate?
    >
    > Example:
    > Input date in my Select: 08/03/2003
    > Output: ID=2
    >
    > Input date in my Select: 08/03/2011
    > Output: NULL
    >
    > How do I have to make my Select?
    >
    >
    > Many thanks in advance for any help!!
    > Andreas
    >
    >

    Tammy B. Guest

  3. #3

    Default Re: HowTo Select an ID where a "Date" is between startDate and endDate?

    Hello Tammy,
    many thanks!!!

    Regards,
    Andreas


    "Tammy B." <Tbstinkylips.com> schrieb im Newsbeitrag
    news:Oe36n9oQDHA.2228tk2msftngp13.phx.gbl...
    > select id from MYTABLE where '08/03/2003' >startDateate and '08/03/2003'<
    > endDate
    >
    >
    > "Andreas Klemt" <aklemt68hotmail.com> wrote in message
    > news:%23B6LsDoQDHA.2636TK2MSFTNGP10.phx.gbl...
    > > Hello,
    > >
    > > I have this table
    > >
    > > ID startDate endDate
    > > -------------------------------
    > > 1 04/01/2003 07/30/2003
    > > 2 08/01/2003 09/30/2003
    > > 3 02/11/2004 04/15/2004
    > >
    > > How can I get the ID when I give in my SELECT a DATE to find out if this
    > > DATE is between
    > > startDate and endDate?
    > >
    > > Example:
    > > Input date in my Select: 08/03/2003
    > > Output: ID=2
    > >
    > > Input date in my Select: 08/03/2011
    > > Output: NULL
    > >
    > > How do I have to make my Select?
    > >
    > >
    > > Many thanks in advance for any help!!
    > > Andreas
    > >
    > >
    >
    >

    Andreas Klemt Guest

Similar Threads

  1. Replies: 0
    Last Post: August 26th, 06:01 AM
  2. #39106 [Opn->Bgs]: date("w") incompatible with date("W")
    By tony2001@php.net in forum PHP Bugs
    Replies: 0
    Last Post: October 10th, 10:53 AM
  3. #39106 [NEW]: date("w") incompatible with date("W")
    By felixmallek at gmx dot de in forum PHP Bugs
    Replies: 0
    Last Post: October 10th, 10:42 AM
  4. where DATE is BETWEEN startdate and enddate...how?
    By Nathon Jones in forum Dreamweaver AppDev
    Replies: 9
    Last Post: March 8th, 01:44 PM
  5. HIDE IF startdate is the same as enddate
    By Nathon Jones in forum Dreamweaver AppDev
    Replies: 2
    Last Post: March 8th, 12:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139