-2

how to exclude holidays from total days ?

how to get the number of public holidays as per US calender ?

<script>
    function labourcostcalc() {
        var date1 = $('#CostMaster_labour_allocationdate').val();
        var date2 = $('#CostMaster_labour_deallocationdate').val();
        var diff;
        if (date1 >= date2) {
            diff = new Date(Date.parse(date1) - Date.parse(date2));
        } else if (date1 < date2) {
            diff = new Date(Date.parse(date2) - Date.parse(date1));
        }
        alert('Diff  date ' + diff);
        var days = diff / 1000 / 60 / 60 / 24;
        alert(days);
    }
</script>
Anton
  • 32,245
  • 5
  • 44
  • 54
user3378215
  • 117
  • 1
  • 2
  • 9

1 Answers1

1

You'll need to store this holidays somewhere or query a public service that provides that information for you. You can save a list of dates in your database and query (count) than by range using ajax

$.get('/yourservice/getdates',{begin: date1, end: date2}, function(holidaysCount) {
   days -= holidaysCount;
});

In your server you will need to create a table and a query like this

select count(1) from holidays where holiday_date between :date1 and :date2
Augusto
  • 1,234
  • 1
  • 16
  • 35