Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Date Between Problem

Date Between Problem

Scheduled Pinned Locked Moved Database
databasehelp
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Babu R K
    wrote on last edited by
    #1

    Hi, I have a typical scenario. I want to get My query is SELECT StarRate, date FROM BasicSearch WHERE date BETWEEN '2008-06-03' AND '2008-06-05'; My Result is as follows StarRate date -------- ----- 1 2008-06-03 00:00:00.000 1 2008-06-04 00:00:00.000 1 2008-06-05 00:00:00.000 5 2008-06-04 00:00:00.000 5 2008-06-05 00:00:00.000 But I require the result as below StarRate date -------- ----- 1 2008-06-03 00:00:00.000 1 2008-06-04 00:00:00.000 1 2008-06-05 00:00:00.000 Because StarRate 1 has all 3 dates Thanks in advance

    A K N 3 Replies Last reply
    0
    • B Babu R K

      Hi, I have a typical scenario. I want to get My query is SELECT StarRate, date FROM BasicSearch WHERE date BETWEEN '2008-06-03' AND '2008-06-05'; My Result is as follows StarRate date -------- ----- 1 2008-06-03 00:00:00.000 1 2008-06-04 00:00:00.000 1 2008-06-05 00:00:00.000 5 2008-06-04 00:00:00.000 5 2008-06-05 00:00:00.000 But I require the result as below StarRate date -------- ----- 1 2008-06-03 00:00:00.000 1 2008-06-04 00:00:00.000 1 2008-06-05 00:00:00.000 Because StarRate 1 has all 3 dates Thanks in advance

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #2

      SELECT DISTINCT StarRate, date FROM BasicSearch WHERE date BETWEEN '2008-06-03' AND '2008-06-05';

      Bob Ashfield Consultants Ltd

      1 Reply Last reply
      0
      • B Babu R K

        Hi, I have a typical scenario. I want to get My query is SELECT StarRate, date FROM BasicSearch WHERE date BETWEEN '2008-06-03' AND '2008-06-05'; My Result is as follows StarRate date -------- ----- 1 2008-06-03 00:00:00.000 1 2008-06-04 00:00:00.000 1 2008-06-05 00:00:00.000 5 2008-06-04 00:00:00.000 5 2008-06-05 00:00:00.000 But I require the result as below StarRate date -------- ----- 1 2008-06-03 00:00:00.000 1 2008-06-04 00:00:00.000 1 2008-06-05 00:00:00.000 Because StarRate 1 has all 3 dates Thanks in advance

        K Offline
        K Offline
        Kjetil Svendsen
        wrote on last edited by
        #3

        Hi Do you want the output to be only the StarRate witch has all the dates in the date interval? Try

        SELECT StarRate, date FROM BasicSearch WHERE date BETWEEN '2008-06-03' AND '2008-06-05'
        AND StarRate in (
        SELECT StarRate FROM BasicSearch WHERE date BETWEEN '2008-06-03' AND '2008-06-05'
        GROUP BY StarRate
        HAVING Count(*) = DATEDIFF("D", '2008-06-03', '2008-06-05') + 1)

        This should work if it's uniqueness on StarRate and date Kjetil

        A 1 Reply Last reply
        0
        • K Kjetil Svendsen

          Hi Do you want the output to be only the StarRate witch has all the dates in the date interval? Try

          SELECT StarRate, date FROM BasicSearch WHERE date BETWEEN '2008-06-03' AND '2008-06-05'
          AND StarRate in (
          SELECT StarRate FROM BasicSearch WHERE date BETWEEN '2008-06-03' AND '2008-06-05'
          GROUP BY StarRate
          HAVING Count(*) = DATEDIFF("D", '2008-06-03', '2008-06-05') + 1)

          This should work if it's uniqueness on StarRate and date Kjetil

          A Offline
          A Offline
          Ashfield
          wrote on last edited by
          #4

          Nice one. I think I misread the original post, didn't notive it was just the starrate 1's required.

          Bob Ashfield Consultants Ltd

          1 Reply Last reply
          0
          • B Babu R K

            Hi, I have a typical scenario. I want to get My query is SELECT StarRate, date FROM BasicSearch WHERE date BETWEEN '2008-06-03' AND '2008-06-05'; My Result is as follows StarRate date -------- ----- 1 2008-06-03 00:00:00.000 1 2008-06-04 00:00:00.000 1 2008-06-05 00:00:00.000 5 2008-06-04 00:00:00.000 5 2008-06-05 00:00:00.000 But I require the result as below StarRate date -------- ----- 1 2008-06-03 00:00:00.000 1 2008-06-04 00:00:00.000 1 2008-06-05 00:00:00.000 Because StarRate 1 has all 3 dates Thanks in advance

            N Offline
            N Offline
            Niraj_Silver
            wrote on last edited by
            #5

            hi...

            SELECT StarRate, date FROM BasicSearch WHERE date BETWEEN '2008-06-03' AND '2008-06-05'
            Order By Date

            By.. Tc :-D

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups