I need to be able to run a function as part of my SQL statement. The function is running some calculations that (when completed) will be averaged by using groups. I have no problems running the function separately, however, I need to create reports that are grouped by user locations. with this particular piece of information the result of the grouping, here's what I have in Access:
SELECT Region, Marketplace, Branch, Avg(Workday([TimeStamp],Now())) AS DaysIgnored
FROM TBL_MasterData
WHERE (((Status)="New")
GROUP BY Region, Marketplace, Branch;
My problem is when I try to run the function in ASP - I can play with the "& WorkDay &" stuff and get some things to return, however, I can't get it to run the actual calculation... The Workday calculation takes two inputs, StartDate and EndDate.
Here's what I've tried (simplified - extra fields removed, just trying to get it to work)
Basic try - just tells me that it is an undefined function
Set rst1 = cnn1.Execute("SELECT Workday(TimeStamp,Now()) AS DaysIgnored FROM TBL_MasterData;"
By opening and closing the function in quotes... works, but doesn't pull the TimeStamp field from the table for calculation
Set rst1 = cnn1.Execute("SELECT " & Workday(TimeStamp,Now()) &" AS DaysIgnored FROM TBL_MasterData;"
By messing with the quotes to try and get the TimeStamp field, it doesn't like the quotes in the function
Set rst1 = cnn1.Execute("SELECT " & Workday( &" TimeStamp "& ,Now()) &" AS DaysIgnored FROM TBL_MasterData;"
Eventually, I'll need to do an AVG on this field then return the results grouped by location info. That's where the dilemma comes in for me - I can run the function outside the SQL statement - but it's rather hard averaging dates, especially when I'm removing holidays from the date difference... the calculation gives me an number that I can then use the AVG on...
Any help is greatly appreciated!
Thanks,
Kenneth Frazier, MCSE, CCA
Network Engineer
SELECT Region, Marketplace, Branch, Avg(Workday([TimeStamp],Now())) AS DaysIgnored
FROM TBL_MasterData
WHERE (((Status)="New")
GROUP BY Region, Marketplace, Branch;
My problem is when I try to run the function in ASP - I can play with the "& WorkDay &" stuff and get some things to return, however, I can't get it to run the actual calculation... The Workday calculation takes two inputs, StartDate and EndDate.
Here's what I've tried (simplified - extra fields removed, just trying to get it to work)
Basic try - just tells me that it is an undefined function
Set rst1 = cnn1.Execute("SELECT Workday(TimeStamp,Now()) AS DaysIgnored FROM TBL_MasterData;"
By opening and closing the function in quotes... works, but doesn't pull the TimeStamp field from the table for calculation
Set rst1 = cnn1.Execute("SELECT " & Workday(TimeStamp,Now()) &" AS DaysIgnored FROM TBL_MasterData;"
By messing with the quotes to try and get the TimeStamp field, it doesn't like the quotes in the function
Set rst1 = cnn1.Execute("SELECT " & Workday( &" TimeStamp "& ,Now()) &" AS DaysIgnored FROM TBL_MasterData;"
Eventually, I'll need to do an AVG on this field then return the results grouped by location info. That's where the dilemma comes in for me - I can run the function outside the SQL statement - but it's rather hard averaging dates, especially when I'm removing holidays from the date difference... the calculation gives me an number that I can then use the AVG on...
Any help is greatly appreciated!
Thanks,
Kenneth Frazier, MCSE, CCA
Network Engineer