2 Replies Latest reply on Mar 31, 2014 8:16 AM by UpStyleDesign

# Trying to calculate value based on rounding up and then calculate date range excluding weekends..

Hi

I am creating a simple design studion project request form where the user can enter how many photographs need to be ordered. I am calling this field 'NumImages'. Then once the data is entered, another field (I am calling this NumDaysImage) will be calculated based on the fact that no more than 5 photographs can be shot per day. So, 1-5  photos = 1 day. 6-10 photos = 2 days. 11-15 photos = 3 days etc. I do not need to calculate part days, so 6 photos is the same as 10 i.e. 2 days.

Once I have calcuated 'NumDaysImage', I then need to calculate an end date called 'DateDue'. The start date is entered by the user in the field 'DateStart'.

I know this is not going to be easy, but how can I calculate 'DateDue' based on a Mon-Fri working week, and ideally excluding UK public holidays?

Also on the form is a value 'NumDays' that is the number of days for designing the brochure for the photos. This value I have calculated already, but it will need to be added to 'NumDaysImage' to get a total number of production days that is then used to calculate 'DateDue'.

Any help will be greatly appreciated. Thanks.

• ###### 1. Re: Trying to calculate value based on rounding up and then calculate date range excluding weekends..

JavaScript has the Math.ceil method which rounds up a number to the next integer if it is not an integer.

Dates are more complicated calculation as the starting date needs to be converted to a number and then one can calculate the ending date and test that date to see if is a Sunday or Saturday. Do intervening weekends add to the number of days for processing.

• ###### 2. Re: Trying to calculate value based on rounding up and then calculate date range excluding weekends..

Intervening weekends do indeed add to the number of days for processing. I am a total newbie on this, so thanks for the pointers.