🔥 The DB Grill 🔥

Where database blog posts get flame-broiled to perfection

How to compute the difference between two timestamps in specific units using age() in ClickHouse®
Originally from tinybird.co/blog-posts
September 18, 2025 • Roasted by Rick "The Relic" Thompson Read Original Article

Alright, settle down, kid. Let me see what shiny new bauble the internet has coughed up today. [He squints at the screen, a low grumble rumbling in his chest.]

"Learn how to use ClickHouse's age() function..." Oh, this is precious. You kids and your fancy function names. age(). How... approachable. You've finally managed to reinvent the DATEDIFF function that's been in every half-decent SQL dialect since before your lead developer was a glimmer in the milkman's eye. Congratulations. Slap a new coat of paint on it, write a blog post, and call it innovation.

Let's see here... "calculate complete time units between timestamps, from nanoseconds to years."

Nanoseconds.

Let that sink in. You're using an OLAP database, designed for massive analytical queries over petabytes of data, and you're bragging about calculating the time between two events down to the billionth of a second.

Back in my day, we were happy if the batch job that calculated the quarterly sales reports finished before the sun came up. We measured time in "number of coffee pots brewed" and "how many cigarettes I can smoke before the tape drive whirs to a stop." You're worried about nanoseconds? I once had to restore a corrupted customer master file from a set of tapes stored off-site. One of them had been sitting next to a large speaker in the courier's van. We measured that data loss in "number of executives hyperventilating." Believe me, nobody was asking for a nanosecond-level post-mortem.

...with syntax examples and practical queries.

Oh, I bet they're practical. Let me guess: “Calculate the average user session length for our synergistic, hyper-scaled, cloud-native web portal down to the femtosecond to optimize engagement.”

You know what a "practical query" was in 1985? It was a ream of green bar paper hitting my desk, smelling of fresh ink, with a COBOL program's output showing that everyone's paycheck was correct. The "syntax" was a hundred lines of JCL so arcane it could have been used to summon a demon, and you prayed to whatever deity you favored that you didn't misplace a single comma, lest you spend the next six hours trying to decipher a cryptic error code.

This age() function... it’s cute. It’s like watching a toddler discover their own feet. We did this with simple subtraction in our DB2 stored procedures. You just... subtracted the start date from the end date. Got a number. Then you did the math to turn it into days, months, whatever. It wasn't a built-in feature, it was arithmetic. We were expected to know how to do it ourselves. We didn't need the database to hold our hand and give us a special function named after a condescending question your doctor asks you.

And the name... "ClickHouse." Sounds fast. Sounds disposable. Like one of those electric scooters everyone leaves littered on the sidewalk. We had names that commanded respect. IMS. IDMS. DB2. They sounded like industrial machinery because that's what they were. They were heavy, they were loud, and they outlived the people who built them.

So go on, be proud of your little age() function. Write your blog posts. Celebrate your nanoseconds. Just know that everything you think is revolutionary is just a simplified, less-robust version of something we were doing on a System/370 mainframe while you were still learning how to use a fork.

Now if you'll excuse me, I think I have a punch card in my wallet with a more elegant solution written on it.