If I wanted to determine today's date based on my birthdate, how could I do that mathematically? Let's say for example my birthday is August 17, 1996. Each year has 365 days except leap years. If I didn't know whether 1996 was a leap year or not, is there a way I can see how many days I've been alive (obviously without looking at a calendar or manually counting). And from my birthdate, how can I (if possible) deduce what today's date is?
 A: There is a very simple solution (assuming that you can use programs) : convert  dates to Julian days and subract the two numbers.
For example, in the book "Numerical Recipes" you could find a subroutine named julday.
You also could find a source code here.
For example, today $(07/28/2017)$ is $2457963$ and your birthday $(08/17/1996)$ is $2450313$ which makes a difference of $7650$.
You can use the method for any other situation.
A: I wrote a small program (I am a beginner programmer, so it may not be a very efficient way of doing this) to compute the number of days passed between two dates. One would enter the first date in the form D/M/Y and then the second in the same form, and this will spit out the number of days in between. I used C++.
#include <iostream>
#include <string>
#include <math.h>
#include <cmath>
#include <utility>
#include <sstream>
#include <cmath>
#include <vector>
#include <tuple>
#include <algorithm>
#include <iterator>
using namespace std;

//Leap year check
bool leapyearcheck (long double y)
{
    if ((y/4==floor(y/4)) && (y/100!=floor(y/100)))
    {
        return true;
    }
    else if (y/400==floor(y/400))
    {
        return true;
    }
    else
    {
        return false;
    }
}

//Month counter
long double counter_month (long double d, long double m, long double y)
{
    if (m==1)
    {
        return 0;
    }
    else if (m==2)
    {
        return 31;
    }
    else if ((m==3) && (leapyearcheck(y)==true))
    {
        return 60;
    }
    else if ((m==3) && (leapyearcheck(y)==false))
    {
        return 59;
    }
    else if ((m==4) && (leapyearcheck(y)==true))
    {
        return 91;
    }
    else if ((m==4) && (leapyearcheck(y)==false))
    {
        return 90;
    }
    else if ((m==5) && (leapyearcheck(y)==true))
    {
        return 121;
    }
    else if ((m==5) && (leapyearcheck(y)==false))
    {
        return 120;
    }
    else if ((m==6) && (leapyearcheck(y)==true))
    {
        return 152;
    }
    else if ((m==6) && (leapyearcheck(y)==false))
    {
        return 151;
    }
    else if ((m==7) && (leapyearcheck(y)==true))
    {
        return 182;
    }
    else if ((m==7) && (leapyearcheck(y)==false))
    {
        return 181;
    }
    else if ((m==8) && (leapyearcheck(y)==true))
    {
        return 213;
    }
    else if ((m==8) && (leapyearcheck(y)==false))
    {
        return 212;
    }
    else if ((m==9) && (leapyearcheck(y)==true))
    {
        return 244;
    }
    else if ((m==9) && (leapyearcheck(y)==false))
    {
        return 243;
    }
    else if ((m==10) && (leapyearcheck(y)==true))
    {
        return 274;
    }
    else if ((m==10) && (leapyearcheck(y)==false))
    {
        return 273;
    }
    else if ((m==11) && (leapyearcheck(y)==true))
    {
        return 305;
    }
    else if ((m==11) && (leapyearcheck(y)==false))
    {
        return 304;
    }
    else if ((m==12) && (leapyearcheck(y)==true))
    {
        return 334;
    }
    else if ((m==12) && (leapyearcheck(y)==false))
    {
        return 335;
    }
}

//Year counter
long double counter_year (long double d, long double m, long double y)
{
    long double a=0;
    long double b=0;
    for (long double j=0;j<y;j++)
    {
        if (leapyearcheck(j)==true)
        {
            a++;
        }
        else if (leapyearcheck(j)==false)
        {
            b++;
        }
    }
    return 366*a+365*b;
}

//Main counter
long double counter_main (long double d, long double m, long double y)
{
    return counter_month(d,m,y)+counter_year(d,m,y)+d;
}

//Days difference
long double daysdiff (long double d_1, long double m_1, long double y_1, long double d_2, long double m_2, long double y_2)
{
    return counter_main(d_2,m_2,y_2)-counter_main(d_1,m_1,y_1);
}

//String to date
vector<long double> stodate (string input)
{
    long double d,m,y;
    istringstream ss(input);
    string entry="";
    int index=0;
    while (getline(ss,entry,'/'))
    {
        if (index==0)
        {
            d=stold(entry);
        }
        else if (index==1)
        {
            m=stold(entry);
        }
        else if (index==2)
        {
            y=stold(entry);
        }
        index++;
    }
    vector<long double> date(3);
    date[0]=d;
    date[1]=m;
    date[2]=y;
    return date;
} 

//Output
int main()
{
    long double d_1,m_1,y_1,d_2,m_2,y_2;
    string startdate, enddate;
    cout << "Enter the start date (D/M/Y): ";
    cin >> startdate;
    cout <<"\nEnter the end date (D/M/Y): ";
    cin >> enddate;
    d_1=stodate(startdate)[0];
    m_1=stodate(startdate)[1];
    y_1=stodate(startdate)[2];
    d_2=stodate(enddate)[0];
    m_2=stodate(enddate)[1];
    y_2=stodate(enddate)[2];
    cout << "\nThe number of days passed is: " << daysdiff(d_1,m_1,y_1,d_2,m_2,y_2);
}


I create functions to count the number of days produced by the number of years, months, and then days of each date. Then I subtract the two numbers obtained from each date to obtain the number of days passed between the two dates. The number of days for the months is $31$ if it is February, for instance (i.e. if someone inputs 2 as the month, then $31$ days have passed since the beginning of that year until this month). The only tricky part is with leap years, in which a leap year occurs if $$(4\mid y~\land~100\nmid y)\lor(400\mid y)$$where $y$ denotes the year.
For your birthdate: August 17, 1996, we would input 17/8/1996 as the start date, and then today's date as the end date (the day I posted this is 30/7/2017). On the day I posted this, you would be $7652$ days old.
A: I don't know if this is an acceptable answer, but you can do
1) An SQL Server query using the DateDiff function, a "" function with inputs ( DatePart, Date 1, Date 2) where DatePart is the "Gradation" : Years, Months, Days, etc. 
Select DateDiff( Days, Date1, Date2) , where Date1 is your DOB, Date2 is the date for which you want to find the number of days passed. You can run it for free here: https://www.w3schools.com/sql/func_datediff.asp
OR
2) Use a perpetual calendar https://accuracyproject.org/perpetualcalendars.html: There are 14 possible day arrangements for a calendar: Once the date of January 1st and whether the year is a leap year or not, the calendar is determined : Jan 1st can fall on Mon through Sunday , and the year is either leap or non-leap. Just look up the year number and look up the calendar for that year.
