Title: Calculating date without weekends
Last modified: January 24, 2017

---

# Calculating date without weekends

 *  Resolved [troxx](https://wordpress.org/support/users/troxx/)
 * (@troxx)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/calculating-date-without-weekends/)
 * Hello, I need a simple calculation – user picks a date and desired service, to
   calculate when the service would be finished. Simple “cdate(fieldname1+fieldname7)”
   BUT – how can I omit Saturdays and Sundays from the calculation?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/calculating-date-without-weekends/#post-8693980)
 * Hello [@troxx](https://wordpress.org/support/users/troxx/),
 * I’ll assume the fieldname1 is a date field, and the fieldname7 a number field
   with the amount of working days, a simple way to implement it would be:
 *     ```
       (function(){
          var d = new Date(fieldname1*86400000), c = fieldname7;
          while(0< c)
          {
             d.setDate(d.getDate()+1); 
             if(d.getDay() != 0 && d.getDay() != 6)
             c--;
         }
         return cdate(d.valueOf()/86400000);
       })()
       ```
   
 * Best regards.
 *  Thread Starter [troxx](https://wordpress.org/support/users/troxx/)
 * (@troxx)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/calculating-date-without-weekends/#post-8727229)
 * It works! Thanks a lot!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Calculating date without weekends’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [troxx](https://wordpress.org/support/users/troxx/)
 * Last activity: [9 years, 4 months ago](https://wordpress.org/support/topic/calculating-date-without-weekends/#post-8727229)
 * Status: resolved