BIRT Exchange Forum: Date Parameter - BIRT Exchange Forum

Jump to content


 

BIRT Poll: Have you ever done any development work on mobile?

Yes - lotsYes - someNo - but plan toNo time or interestWhat is mobile?
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Date Parameter Rate Topic: -----

#1 User is offline   olivia08 Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 28
  • Joined: 29-February 12


Posted 04 June 2012 - 08:38 AM

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?
0

#2 User is offline   bgbaird Icon

  • Senior Member
  • Group: Members
  • Posts: 114
  • Joined: 25-February 10


Posted 04 June 2012 - 01:00 PM

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
0

#3 User is offline   olivia08 Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 28
  • Joined: 29-February 12


Posted 08 June 2012 - 12:54 PM

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?
0

#4 User is offline   bgbaird Icon

  • Senior Member
  • Group: Members
  • Posts: 114
  • Joined: 25-February 10


Posted 11 June 2012 - 10:28 AM

Olivia,

I have NO idea why, but try this instead...

if(BirtDateTime.diffDay(params["dateValidation"].value,BirtDateTime.today()) < 365)
{true;}
else
{false;}
0

#5 User is offline   olivia08 Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 28
  • Joined: 29-February 12


Posted 13 June 2012 - 02:26 PM

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".
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users