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:
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
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"
Thanks
bc