The trick works like this: Take the current date in the format yyyymmdd and subtract it with your date of birth taken in the same format. Drop the last four digits to get your age.

For example, I was born in August 20th, 1994. Today it is July 13th, 2015.

$$ 20150713 - 19940820 = 209893\\ \textrm{Dropping the last four digits,}\\ \textrm{My age}=20 $$

I can understand subtracting two years, but how does crafting these numbers with month and day make it more accurate?

  • 37
    $\begingroup$ You look much younger in your profile picture. $\endgroup$ Commented Jul 13, 2015 at 7:10
  • 5
    $\begingroup$ @JoonasIlmavirta Lisa Simpson was eight years old back in 1989. That would make her well over 30. $\endgroup$
    – Arthur
    Commented Jul 13, 2015 at 7:21
  • 6
    $\begingroup$ @Arthur, true, but the picture does give a somewhat younger impression. (I hope we don't need to resort to relativistic arguments explaining how slowly people age in Springfield.) $\endgroup$ Commented Jul 13, 2015 at 7:30
  • 1
    $\begingroup$ yyyymmdd = year*10000 + month*100 + day $\endgroup$
    – Sanya_Zol
    Commented Jul 13, 2015 at 17:53
  • 2
    $\begingroup$ @Arthur Did you use this trick to determine that? $\endgroup$
    – corsiKa
    Commented Jul 13, 2015 at 18:46

3 Answers 3


Subtracting the month and day lets you take into account whether you've had your birthday this year. If you have had your birthday, then you can just skip the month and day, they don't affect the two years at all (do the subtraction by hand to see this more clearly). If you haven't had your birthday yet, then the process of borrowing will subtract a year for you.

  • $\begingroup$ Thank you for the answer. Also, will it give an answer with even more precision if we include hours, minutes and seconds? $\endgroup$
    – user41235
    Commented Jul 13, 2015 at 19:24
  • 8
    $\begingroup$ @RenaeLider Yes it would. That would allow the calculation to work even on your birthday such that if your birth time has passed, it will calculate you to be a year older but not if your birth time has not passed. The current formula will say that you are a year older on your birthday, even if the birth time hasn't passed. $\endgroup$
    – Daniel
    Commented Jul 13, 2015 at 19:46

$$\large\begin{align*} \hphantom{-}(\mathsf{year}_1)(\mathsf{month}_1)(\mathsf{day}_1)\\ -(\mathsf{year}_2)(\mathsf{month}_2)(\mathsf{day}_2) \end{align*}$$ is equal to $$\large\begin{cases} \hphantom{{}-1}(\mathsf{year}_1-\mathsf{year}_2)\Box\Box\Box\Box&\;\textsf{if }(\mathsf{month}_1)(\mathsf{day}_1)\geq (\mathsf{month}_2)(\mathsf{day}_2)\\ (\mathsf{year}_1-\mathsf{year}_2-1)\Box\Box\Box\Box&\;\textsf{if }(\mathsf{month}_1)(\mathsf{day}_1)< (\mathsf{month}_2)(\mathsf{day}_2)\\ \end{cases}$$

  • 1
    $\begingroup$ My browser is not rendering all of those characters. Can you find an alternative way to present the special characters? $\endgroup$ Commented Jul 13, 2015 at 21:27
  • 4
    $\begingroup$ @LightnessRacesinOrbit Looking at the markdown I think those boxes are actually deliberate. I'm guessing it's a way of saying "it doesn't matter what's in these places". $\endgroup$ Commented Jul 13, 2015 at 21:56
  • $\begingroup$ @ChrisHayes: Hmm I see! I'm not an expert on mathematical notation but is this conventional? It confused me somewhat :( $\endgroup$ Commented Jul 13, 2015 at 22:33
  • $\begingroup$ @LightnessRacesinOrbit I'm no expert myself, so I couldn't say. I don't think questions of this type, where the exact placement of the digits is important but some of those digits can be ignored, come up that often, so it may not be all that standard. $\endgroup$ Commented Jul 13, 2015 at 22:37
  • 1
    $\begingroup$ When writing matrices for example, the symbol $\ast$ is common for unspecified entries. $\endgroup$
    – quid
    Commented Jul 14, 2015 at 11:41

You just have to check two cases, if $mmdd$ of the day you where born is more than current $mmdd$ then the first $4$ digits will be $yyyy-1$. If $mmdd$ of the day you where born is less or eqaul to current $mmdd$ then you get $yyyy$ as answer. Which is correct in both cases.

  • $\begingroup$ helpful! thanks $\endgroup$
    – wa7d
    Commented Jul 22, 2017 at 5:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .