Wednesday, January 16, 2019

How Many Hours Old are You? Calculating with SQL.

Do you like to feel the inexorable passing of time? People wish they were older until they reach 21, and then they wish they were younger. Well, if you don't like that feeling, it's because you're measuring it wrong. You should be measuring your age in hours. Then you will get a different feeling. Not the warm and fuzzies, but more of a feeling of incredulity. You won't believe that your age in hours is such a short timespan. There's something to make you feel young.

So, how old do you think you are, in hours?

This is an observation about time, that was triggered by a SQL query I was doing.

If you're a math geek, you might multiply in your head the following: your age times 365 (days) times 24 (hours in a day), which gives you an estimate. You'd need to narrow it down more by knowing your age in years and days.

If you're like me and prefer your calculations done by a database, then read on... all you need is a database connection, and you can have it calculate your age in units of hours with this handy snippet (this is for Oracle).


SELECT
    24 * TRUNC(sysdate - to_date('1919-07-15 08:00', 'YYYY-MM-DD hh24:mi')) as Hours_Old
FROM DUAL

That's how many hours a 100-year-old person is right now. What do you think the magic number is? You'd think it's easily in the millions, correct?

Well no. This is more like it.


That makes you think. A 100-year-old person has spent 876,624 hours on this Earth. You'd think that we have more hours, right? You'd think it was a huge amount of hours, and it actually is, but it's not the same as when we think of dollars and we consider millions of dollars to be worth something. Our hours on Earth are a finite amount, so the observation/advice is to make the best out of your limited amount of hours on Earth.

No comments: