Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Date Parameter
olivia08
I have a report that has two text date/time report parameters (Begin and End date). How can I add validation to these date parameters? For example, I would like the Begin date to be > than the (End date minus 12 months) since we are only storing one years worth of data?
Find more posts tagged with
Comments
bgbaird
Putting a parameter validate script in the endDate will work:
if( BirtDateTime.diffDay(params["StartDate"].value,params["EndDate"].value) >=1 )
{true;}
else{false;}
Good luck, Brian
olivia08
Well that got me closer to a solution but not quite. I happen to know that our db table will only have 1 year of data in it from today's date. So when a user puts in their Begin date, I want to put a check that it does not exceed one previous year from today (for example the Begin date cannot be before June 8, 2011).
So I tried this but keep getting an error:
if(BirtDateTime.diffDay(BirtDateTime.today(), params["Begin"].value) > 365)
{true;}
else
{false;}
Any thoughts as too what I'm doing wrong or another way to do it?
bgbaird
Olivia,
I have NO idea why, but try this instead...
if(BirtDateTime.diffDay(params["dateValidation"].value,BirtDateTime.today()) < 365)
{true;}
else
{false;}
olivia08
Thanks...That seemed to work. Last question on this..Is there any way to create a more user friendly error? Currently it displays "...ReportServiceException:The validation for parameter "Begin" fails.". I'd like to have a more descriptive message that tells the user why it failed. Perhaps something like "The Begin date cannot be more than 1 year old" or "You have entered an invalid Begin date".