Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6178965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:33:52+00:00 2026-05-24T00:33:52+00:00

I have been working with OrangeHRM for a project. It uses the Yui Calendar.

  • 0

I have been working with OrangeHRM for a project. It uses the Yui Calendar. I have been working on the leave module. The Leave module lets the user choose a From and To Date – A time frame for which he wants to apply leave !

I want to show the number of Working Days once the user has chosen the dates . A Simple Subtract statement would not work because I want to exclude the Saturdays and Sundays from the equations since they don’t count as working days !

function fillToDate(frmLeaveApp) {

    var fromdate = frmLeaveApp.elements['txtLeaveFromDate'];
        var todate = frmLeaveApp.elements['txtLeaveToDate'];
            var result = frmLeaveApp.elements['txtLeaveTotalDay'];

     if(!fromdate || !todate || !result) {
        return;
    }

        var a = fromdate.value;
        var b = todate.value;

        var c = a.split('-');
        var d = b.split('-');

        var ac = new Date();
        ac.setFullYear(c[2], c[1], c[0]);
        var bd = new Date();
        bd.setFullYear(d[2], d[1], d[0]);

        result.value = (bd.getTime() - ac.getTime()) / (60*60*24*1000);
}

How do I do it ? Thanks in advance !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:33:53+00:00Added an answer on May 24, 2026 at 12:33 am

    Not super proud of this solution – must be more elegant ways, but it should work – does not handle national holidays yet

    Demo here

    function fillToDate(frmLeaveApp) {
    
        var fromdate = frmLeaveApp.elements['txtLeaveFromDate'];
        var todate = frmLeaveApp.elements['txtLeaveToDate'];
        var result = frmLeaveApp.elements['txtLeaveTotalDay'];
    
        if(!fromdate || !todate || !result) {
            return;
        }
    
        var from = new Date(fromdate.value.replace(/\-/g,"/"));
        var to = new Date(todate.value.replace(/\-/g,"/"));
    
        // brute force seems the quickest to find
        var res = 0;
        var aDay = 24*60*60*1000;
        for (var i = from.getTime(), n=to.getTime();i < n; i+=aDay) {
          var d = new Date(i).getDay();
          if (d!=0 && d !=6) res++;
        }
        result.value = res;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on a project where I send strings from a client
I have been working on a project in C# (.net4). Project pretty much allows
I have been working on a project on and off, but I haven't touched
I have been working on a huge ETL project with 150+ tables and during
I have been working on a jquery plugin that uses a HTML5 audio player
I have been working Quartz framework in my grails project with lib called quartz-all-1.7.3.
I have been working on a Notes integration project and I am using the
I have been working to upgrade a Postgresql database from 8.4 to 9.1. I
I have been working on a project that displays data in an XML file.
I have been working on a C++ project that links to a .so(dynamic library)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.