March 26, 2015 at 1:22 pm
Hi
I'm looking to validate a Start Date parameter, so a user cannot enter a date greater than 60 days old.
Any information would be very much appreciated
Thanks
Joe
March 26, 2015 at 1:59 pm
use a query to provide available values.
Something like
select thedate from dates where thedate>=dateadd(day,-60,getdate())
MM
select geometry::STGeomFromWKB(0x0106000000020000000103000000010000000B0000001000000000000840000000000000003DD8CCCCCCCCCC0840000000000000003DD8CCCCCCCCCC08408014AE47E17AFC3F040000000000104000CDCCCCCCCCEC3F9C999999999913408014AE47E17AFC3F9C99999999991340000000000000003D0000000000001440000000000000003D000000000000144000000000000000400400000000001040000000000000F03F100000000000084000000000000000401000000000000840000000000000003D0103000000010000000B000000000000000000143D000000000000003D009E99999999B93F000000000000003D009E99999999B93F8014AE47E17AFC3F400000000000F03F00CDCCCCCCCCEC3FA06666666666FE3F8014AE47E17AFC3FA06666666666FE3F000000000000003D1800000000000040000000000000003D18000000000000400000000000000040400000000000F03F000000000000F03F000000000000143D0000000000000040000000000000143D000000000000003D, 0);
March 26, 2015 at 3:25 pm
Just to add to what Magoo said, if you don't have a dates table (and can't create one) you could create a stored proc that produces one like so (just change the number in the TOP clause to match the desired number of dates.)
WITH
L1(N) AS (SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1),
L3(N) AS (SELECT 1 FROM L1 a CROSS JOIN L1 b CROSS JOIN L1 c),
L9(N) AS (SELECT ROW_NUMBER() OVER (ORDER BY (SELECT 1)) FROM l3 a CROSS JOIN L3 b)
SELECT TOP (200) CAST(dateadd(day,n,getdate()-60) AS date) AS thedate
FROM L9;
You will, however, lose the calendar control. If that is not acceptable you could also create an error message text box that is only visible if your date parameter is older than 60 days. The rest of the report would only be visible provided that the date parameter is NOT older than 60 days. You would set this using the visibility option and an expression. This way if the the user selects a date that is more than 60 days old the report would only return a text box that says, "the date must be within 60 days of today". If that does not makes sense I could add some screenshots.
-- Itzik Ben-Gan 2001
March 27, 2015 at 7:18 am
Hi Alan and Magoo...
Thanks for the info , I do have a dimdate table and it does work, except you're right about losing the calendar control. If when you have a moment explain the error message text box routine, I'd love to try it...
Thanks
Joe
March 27, 2015 at 3:48 pm
Sorry, I almost forgot about this post. I put together an example of how you would do what I was talking about; attached is the RDL so you can just plug it into BIDS or SSDT and run it.
Note the screen shot below...
The report has just one parameter called @TheDate; that's your calendar control.
There are two datasets: SampleData and DateChecker. SampleData feeds the report (it's just nonsense for demo purposes); DateChecker takes @TheDate as a parameter and returns the text, "too old" if @TheDate is older than 60 days; NULL otherwise. It uses this query:
SELECT CASE WHEN @TheDate < getdate()-60 THEN 'too old' END AS datestatus
(note that I prefer SQL to SSRS expressions)...
The Report Body has two items, a tablix and a textbox with my custom error message :hehe: . The textbox is visable based on this expression:
=First(Fields!datestatus.Value, "DataChecker") <> "too old"
The tablix is visable based on
=First(Fields!datestatus.Value, "DataChecker") = "too old"
I got them backwards, but you get the point...
Hopefully that's enough to help you figure out what I'm talking about.
For the Visibility settings for my Text box
-- Itzik Ben-Gan 2001
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply