Hello,
I'm stuck at a roadblock with a report i'm writing. The report is a "template" that will be ran once a month every month and will look back at the previous month's data. What i've invisioned is writing a vb script to load on workbook open asking various questions via "inputbox()" method.
This is a generic query i created to use as an example of how i can use inputbox() and datepart() to create the startdate and enddate in my sql query. The day of the month must be static, however the year and month will not be.
Where querydate is my result of datepart() and inputbox().
how do i code querydate into each of my sql query definitions so when the workbook loads, it gets the information after the user has given the date to the inputbox()? The end result would be taking the 20070731 and breaking it to "querydate + 31".
I hope i've explained this clearly enough, running on nothing but coffee atm
I'm open to suggestions if i'm doing this the retarded/impossible/or hard way.
Thanks,
Marshall
I'm stuck at a roadblock with a report i'm writing. The report is a "template" that will be ran once a month every month and will look back at the previous month's data. What i've invisioned is writing a vb script to load on workbook open asking various questions via "inputbox()" method.
Code:
SET NOCOUNT ON
DECLARE @StartDate DateTime
DECLARE @EndDate DateTime
SET @StartDate = '20070731 10:10:51.450'
SET @EndDate = '20070731 10:11:51.450'
SET ROWCOUNT 100
SET NOCOUNT OFF
SELECT EventTagName = EventHistory.TagName, Value
FROM EventHistory
INNER JOIN AnalogSnapshot ON EventHistory.EventLogKey = AnalogSnapshot.EventLogKey
INNER JOIN SnapshotTag ON SnapshotTag.SnapshotTagKey = AnalogSnapshot.SnapshotTagKey
WHERE SnapshotTag.TagName IN ('SysSpaceMain')
AND DateTime >= @StartDate
AND DateTime <= @EndDate
AND SnapshotTag.TagType = 1
AND Quality = 0
SET ROWCOUNT 0
This is a generic query i created to use as an example of how i can use inputbox() and datepart() to create the startdate and enddate in my sql query. The day of the month must be static, however the year and month will not be.
Code:
dim querydate as Integer
Where querydate is my result of datepart() and inputbox().
how do i code querydate into each of my sql query definitions so when the workbook loads, it gets the information after the user has given the date to the inputbox()? The end result would be taking the 20070731 and breaking it to "querydate + 31".
I hope i've explained this clearly enough, running on nothing but coffee atm
I'm open to suggestions if i'm doing this the retarded/impossible/or hard way.
Thanks,
Marshall