By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,379 Members | 1,439 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,379 IT Pros & Developers. It's quick & easy.

Date Between Problem

100+
P: 111
Hi all,

I want to get result for a praricular ID if all days are present.

But I am getting result if any of the day present in between the date


select StarRate, Date from vw_BasicSearch where date BETWEEN CAST('2008-06-03' AS DATETIME)
AND CAST('2008-06-05' AS DATETIME)
AND StarRate = 5
group by StarRate, Date


Result.

StarRate Date
--------------------------

5 2008-06-04 00:00:00.000
5 2008-06-05 00:00:00.000

Thanks
Jun 10 '08 #1
Share this Question
Share on Google+
3 Replies


code green
Expert 100+
P: 1,726
But I am getting result if any of the day present in between the date
That is what the BETWEEN() function does.
I want to get result for a praricular ID if all days are present
Are you looking for a date entry of evey day covering a period. Two months in your example?
Jun 10 '08 #2

deepuv04
Expert 100+
P: 227
hi,
try the following query

Expand|Select|Wrap|Line Numbers
  1. SELECT vw.StarRate, vw.Date
  2. FROM vw_BasicSearch as vw INNER JOIN
  3.     (SELECT StarRate,Count(Distinct Date) AS DAYS
  4.      FROM vw_BasicSearch
  5.      group by code )AS T on T.StarRate = Prod.StarRate
  6.                             AND DAYS = datediff(dd,GETDATE() - 3,GETDATE()) + 1
  7.  
thanks
Jun 10 '08 #3

Delerna
Expert 100+
P: 1,134
nice idea there deepuv
Jun 11 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.