troubleshooting Question

How to use @prompt in choosing dynamic parameters

Avatar of syamsundar
syamsundar asked on
DB Reporting Tools
3 Comments1 Solution1694 ViewsLast Modified:
it looks like user wants to dynamically show data between two dates or two weeks or two months something like that.

I have created the objects and in the webi and made where conditions equal to those objects but been getting nothing but errors.

Below is the code, hope the explanation is clear enough
--FirstDayOfMonth
CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '-' + 
CASE WHEN MONTH(GETDATE())<10 THEN '0' ELSE ' END + 
CAST(MONTH(GETDATE()) AS VARCHAR(2)) + '-01 00:00:00.001' 
 
--LastDayOfMonth
DATEADD(day,
-1,
CAST(YEAR(DATEADD(month,1,GETDATE())) AS VARCHAR(4)) + '-' + 
CASE WHEN MONTH(DATEADD(month,1,GETDATE()))<10 THEN '0' ELSE ' END + 
CAST(MONTH(DATEADD(month,1,GETDATE())) AS VARCHAR(2)) + '-01 23:59:59.998'
) 
 
 
--Prompt for Periodicity
@prompt('DatePeriods','A',{'day','week','month','quarter','year'},Mono,Constrained,Persistent)
 
 
--So the FirstPeriod object would be defined as
DATEADD(@prompt('DatePeriods','A',{'day','week','month','quarter','year'},Mono,Constrained,Persistent)
,@prompt('Num1Begin','N',,Mono,Free,Persistent), CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '-' +  CASE WHEN MONTH(GETDATE())<10 THEN '0' ELSE ' END + CAST(MONTH(GETDATE()) AS VARCHAR(2)) + '-01 00:00:00.001')
 
--And the EndOfPeriod object would be defined as
DATEADD(@prompt('DatePeriods','A',{'day','week','month','quarter','year'},Mono,Constrained,Persistent)
,@prompt('Num1End','N',,Mono,Free,Persistent), DATEADD(day,-1,CAST(YEAR(DATEADD(month,1,GETDATE())) AS VARCHAR(4)) + '-' + CASE WHEN MONTH(DATEADD(month,1,GETDATE()))<10 THEN '0' ELSE ' END + CAST(MONTH(DATEADD(month,1,GETDATE())) AS VARCHAR(2)) + '-01 23:59:59.998'))
ASKER CERTIFIED SOLUTION
wykabryan

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros