Jump to content

Date Validation


Alec

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>

Link to comment
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 comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...