Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Average number of events active each day each month

Status
Not open for further replies.

bcapps

Technical User
Jul 11, 2001
23
US
I am having trouble with a SQL select statement. I have an Access database with a start date and a stop date of an event. I want to know what the average number of events are active each day, each month over the last year. So far my querry is giving me a synatx error. I need help!

Here's the part of the code I'm have trouble with:
Code:
objNum = -11
Do Until objNum = 1
SELECT ((COUNT(eventID) * (SUM(DateDiff('d', IIF(StartDate < Month(DateAdd('m', objNum, Date()))'/1/'YEAR(DateAdd('m', objNum, Date())), Month(DateAdd('m', objNum, Date()))'/1/'YEAR(DateAdd('m', objNum, Date())), StartDate), IIF(IsNull(EndDate, Date(), EndDate)))))/30) AS AvgOpenEvents FROM tblEvents&quot;
Basically here is what I am saying: If the selected event started before the first of the month, set the date to the first, else keep the date of the event, give me the difference between that and the end of the event in number of days, That gives me total number of days for an event, give me the sum of days for all events, and divide that by 30. That gives me the average number of events active each day of the month. Later I will determine the number of days in a month to be more precise, but for now I just need to get past the first part.

Thanks
bc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top