left-arrow-icon
days-since-icon

Days Since Calculator

Date to Date Calculator - Find out how many days since a given date

Home Calculator

Days From / Days Since


Calculate Days between Dates and Time between Dates (Date Counter)

Start Date

      

End Date

      
      
copy icon download icon

Formula to calculate days between two dates

  • To calculate the number of days from a given date, first find the time difference between the 2 dates - start and end date

  • In Javascript, you can use the inbuilt funtion like getTime()

    time diff = Math.abs(endDate.getTime() - startDate.getTime());

  • Convert the time format to days format

    No of Days = timeDiff / (1000 * 3600 * 24);

  • Compute the Years between two dates

    years = Math.floor(number of days / 365);

  • Months between two dates

    months = Math.floor(number of days / 30);

  • Weeks between two dates

    weeks = Math.floor(number of days / 7);

  • To Calculate Hours, Mins and Seconds between two dates

    hours = number of days * 24;

    minutes = number of days * 24 * 60;

    seconds = number of days * 24 * 60 * 60;

How to Calculate No of Work Days between 2 dates?

  • To count days between dates, first get the time in millisecs from both dates

  • Calculate days between start and end dates using getTime() and convert times to days

    millisecondsPerDay = 86400 * 1000;

    startDate.setHours(0, 0, 0, 1);

    endDate.setHours(23, 59, 59, 999);

    time diff = endDate.getTime() - startDate.getTime();

    no of days = Math.ceil(time diff / millisecondsPerDay);

  • Subtract two weekend days for every week in between

    weeks = Math.floor(days / 7);

    days = days - (weeks * 2);

  • Remove weekend not previously removed.

    if (startDay - endDay > 1)

    days = days - 2;

  • Remove start day if span starts on Sunday(0) but ends before Saturday(6)

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

    days = days - 1

  • Remove end day if span ends on Saturday(6) but starts after Sunday(0)

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

    days = days - 1