Ref: Calculate Count by Month Interval

# Thread: Ref: Calculate Count by Month Interval

1. Senior Member
Join Date
Dec 1969
Posts
141

## Ref: Calculate Count by Month Interval

Hi<BR>I have a table with startdate,enddate and headcount.<BR><BR>I want the total headcount with a month difference between the startdate and the enddate.<BR><BR>For e.g If my startdate is 01/01/2003 and enddate is 01/01/2004<BR><BR>I want the sum of headcount between <BR>1)01/01/2003-02/01/2003 20<BR>2)02/01/2003-04/01/2003 60 etc..<BR>This will go on till 2004...<BR><BR><BR>Could you please suggest me an sql query.<BR><BR>Thanks<BR>

2. Senior Member
Join Date
Dec 1969
Posts
141

## RE: Ref: Calculate Count by Month Interval

3. Senior Member
Join Date
Dec 1969
Posts
11,247

## RE: Ref: Calculate Count by Month Interval

Select startDate, enddate, sum(headcount)<BR>Where Dateadd(m, 1, Startdate) = enddate<BR>and startDate &#062;= &#039;" & startdateinput & "&#039;<BR>and endDate &#060;= &#039;" & enddateinput & "&#039;<BR>Group BY startdate, enddate<BR>Order BY startdate, enddate

4. Senior Member
Join Date
Dec 1969
Posts
11,247

## Patience is a virtue <nt>

.

5. Senior Member
Join Date
Dec 1969
Posts
141

## RE: Ref: Calculate Count by Month Interval

Hi White..<BR>I tried the above query but iam unable to get the results.<BR><BR><BR><BR>

6. Senior Member
Join Date
Dec 1969
Posts
11,247

## Show me

debug the query<BR><BR>unable to get the results!<BR> it&#039;s an error?<BR> it&#039;s not producing any results? <BR><BR>WHAT do you mean???

#### Posting Permissions

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