Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Offerid             date         offeravaliable   Emailid 
73           6/8/2014 00:00:00    True             2
74           6/9/2014 00:00:00    True             2
75           6/10/2014 00:00:00   True             2
76           6/11/2014 00:00:00   True             2
77           6/12/2014 00:00:00   True             2
78           6/13/2014 00:00:00   True             2
79           6/14/2014 00:00:00   True             2
80           6/16/2014 00:00:00   True             2
81           6/17/2014 00:00:00   True             4
82           6/18/2014 00:00:00   True             4
83           6/19/2014 00:00:00   True             4
84           6/20/2014 00:00:00   True             4
89           6/27/2014 00:00:00   True             4
90           6/28/2014 00:00:00   True             4
91           6/29/2014 00:00:00   True             4
92           6/30/2014 00:00:00   True             4
93           6/1/2014 00:00:00    True             4
94           6/2/2014 00:00:00    True             4
95           6/3/2014 00:00:00    True             2
96           6/4/2014 00:00:00    True             2
97           6/5/2014 00:00:00    True             2
98           6/6/2014 00:00:00    True             2
99           6/7/2014 00:00:00    True             2
100          6/21/2014 00:00:00   True             4
101          6/22/2014 00:00:00   True             4
102          6/23/2014 00:00:00   True             4
103          6/24/2014 00:00:00   True             4
104          7/1/2014 00:00:00    True             4
105          7/2/2014 00:00:00    True             4
106          7/3/2014 00:00:00    True             4
121          7/6/2014 00:00:00    True             2
122          7/7/2014 00:00:00    True             2
123          7/8/2014 00:00:00    True             2


above record through i can generate below group of all date like as
C#
StartDate - EndDate    EmailID
6/1/2014 -  6/2/2014     4
6/3/2014 -  6/14/2014    2
6/16/2014 - 6/16/2014    2
6/17/2014 - 6/24/2014    4
6/27/2014 - 6/30/2014    4 
7/1/2014  - 7/3/2014     4 


i trying to find, for each EmailID, the contiguous blocks of dates?
any one solve this question
thanks in advance
Posted
Updated 13-Jun-14 20:04pm
v6
Comments
Debabrata_Das 13-Jun-14 6:28am    
What is the criteria to decide Start Date and End Date?
Ashvinrajkot 13-Jun-14 12:18pm    
no criteria for start dates and end dates
because all of the dates generating group wise in EmailDataID
Debabrata_Das 13-Jun-14 12:27pm    
Sorry to say... but I cannot understand the question. Can you explain considering your input how are you generating the output? Take your time and explain properly so that everyone understand your requirement.
Ashvinrajkot 14-Jun-14 0:24am    
in above question offerid 73 to 123 display this is my database value
and i can generate
StartDate - EndDate EmailID
6/1/2014 - 6/2/2014 4
6/3/2014 - 6/16/2014 2
this type output
How to fire query in Page load in asp.net
Sprint89 13-Jun-14 10:14am    
Are you trying to find, for each EmailID, the contiguous blocks of dates?

I.e. if there had been a record on 6/15/2014 for EmailID 2, your second and third lines in your results would be combined into

StartDate - EndDate EmailID
6/3/2014 - 6/16/2014 2

1 solution

try with Group By
SQL
SELECT date,count(*)
WHERE date between @start and @end
GROUP BY date
 
Share this answer
 
Comments
Ashvinrajkot 13-Jun-14 6:14am    
above query generated directly without start and enddate

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900