Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » diffDay with condition(Need to get the numbers of days between 2 dates except specific days in the week for each row)
diffDay with condition [message #1694945] Sun, 10 May 2015 09:21 Go to next message
Ofer Geva is currently offline Ofer GevaFriend
Messages: 1
Registered: May 2015
Junior Member
Hi,

I need your help to calculate how many days exist between 2 dates, except specific days in the week for each row.

I tried "diffDay" function in the "Expression Builder" but I can't see any option to exclude specific days.

For example: If I have the dates:
Start Date: 01/05/2015
End Date: 10/05/2015

I would like to get the the number 5 (No Friday and Saturday are counted)

Does anybody knows away to do it in the "Expression Builder" for each row ?

Thanks for advanced

Ofer
Re: diffDay with condition [message #1695447 is a reply to message #1694945] Thu, 14 May 2015 16:58 Go to previous message
Jesse Freeman is currently offline Jesse FreemanFriend
Messages: 184
Registered: January 2015
Senior Member
There are probably a few ways to accomplish this requirement.

I was able to do it in a computed columns using some javascript like this:
var daysToExcludeCount = 0;
var totalDaysFull = parseInt(BirtDateTime.diffDay(row["ORDERDATE"], row["SHIPPEDDATE"])) + 1;
var day = row["ORDERDATE"];
for(var x=0; x<totalDaysFull; x++){
	if(BirtDateTime.weekDay(day, 1) == 6 || BirtDateTime.weekDay(day, 1) == 7){
		daysToExcludeCount++;
	}
	day = BirtDateTime.addDay(day, 1);
}
var totalDaysModified = totalDaysFull - daysToExcludeCount;
totalDaysModified;


I've also attached a sample report with this code in place for reference.
Previous Topic:report engine and using pojo dataset
Next Topic:Birt bug 364412
Goto Forum:
  


Current Time: Fri Apr 26 23:56:12 GMT 2024

Powered by FUDForum. Page generated in 0.03147 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top