Hi ladies end gent's, here's a challenge?

- In "
**Reporting**" I have 25 number-fields each representing a day where Sales Managers can input sales numbers.

- I also have another app called "
**Date**" where I input total sales days of the month and each morning I input days gone by, and a calculation is made of days left.
- Last I have an app "
**Target**" where I input salestarget once a month.

In "**Reporting**" I sum up the numbers of all 25 fields in a calculation field and then its' possible to calculate:

**INDEX**:

@Sum of sales / @Sum of days passed *@Sum of days left /@Sum of sales-target *100

**PROJECTIONS**:

@Sum of sales /@Sum of days passed *@Sum of Total days

**QUESTION**: Is there a workaround so I can skip the part with changing days gone by, each day?

Instead of calculating dates, I think I would prefer to count how many of the 25 number fields that have been filled out (with 0 as well) so the correct calculations is made in each item because I would get the wrong result if some of the Sales Managers have filled out sales numbers but others have not, and they all refer to the same "**Date**" app.

Alternatively I could count days between two date fields inside the reporting app, but then I would have to change date end each day. Can this code below from Rainar be tweaked to @currentday instead of @enddate? Is there even a javascript code for current -And would that be a solution?

__________________________________________________

var startDate = @DateStart

var endDate = @DateEnd

function workingDaysBetweenDates(startDate, endDate) {

// Validate input

if (endDate < startDate)

return 0;

// Calculate days between dates

var millisecondsPerDay = 86400 * 1000; // Day in milliseconds

startDate.setHours(0,0,0,1); // Start just after midnight

endDate.setHours(23,59,59,999); // End just before midnight

var diff = endDate - startDate; // Milliseconds between datetime objects

var days = Math.ceil(diff / millisecondsPerDay);

// Subtract two weekend days for every week in between

var weeks = Math.floor(days / 7);

var days = days - (weeks * 2);

// Handle special cases

var startDay = startDate.getDay();

var endDay = endDate.getDay();

// Remove weekend not previously removed.

if (startDay - endDay > 1)

days = days - 2;

// Remove start day if span starts on Sunday but ends before Saturday

if (startDay == 0 && endDay != 6)

days = days - 1

// Remove end day if span ends on Saturday but starts after Sunday

if (endDay == 6 && startDay != 0)

days = days - 1

return days;

}

startDate == null || endDate == null ? "" : workingDaysBetweenDates( new Date(startDate) , new Date(endDate))

__________________________________________________

https://help.podio.com/hc/en-us/community/posts/239446088-Calculate-difference-between-to-dates-business-days