Jump to content

Date Validation

Recommended Posts

Hi GuysI have the below script.it sets the previous day of the week in the title of a chart.The If case verfiy if the previous day is Sunday and set it to Friday so we can avoid weekends.Today I noticed I am still seeing Friday on the title!!I tried to put == in the If case, I ended up having Friday as a previous day of tuesday.Anybody can help?!Thanks! <script>/*** Called before generation of chart model to GeneratedChartState.* * @param chart* Chart* @param icsc* IChartScriptContext*/ function beforeGeneration( chart, icsc ){importPackage (Packages.java.text); yesterday = BirtDateTime.addDay(new Date(), -1);df = new SimpleDateFormat("EEEE");stringYesterday = df.format(yesterday).toString();if(stringYesterday = "Sunday"){stringYesterday = "Friday";}chart.getTitle().getLabel().getCaption().setValue("Top 5 Callers on " + stringYesterday);}</Script>

Edited by Alec
Link to post
Share on other sites

you're if statement should be

if(stringYesterday == "Sunday"){  stringYesterday = "Friday";};

note: there's a huge difference between = and ==. It's not like you do one over the other just because the other one doesn't work right. If you know what they are doing, then you will know why to use it, and if something's wrong, then it's probably something else. For the record, you may want to alert or log stringYesterday before the if statement to make sure it's what you think it is. (correct casing, format, etc)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...