# Datediff between two dates

**URL:** https://meta.discourse.org/t/datediff-between-two-dates/323799
**Category:** Data & reporting
**Created:** [August 28, 2024, 3:35pm UTC](https://meta.discourse.org/t/datediff-between-two-dates/323799 "2024-08-28T15:35:06Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [August 28, 2024, 4:12pm UTC](https://meta.discourse.org/t/datediff-between-two-dates/323799/2 "2024-08-28T16:12:32Z")

</div>

> [@SStrong](#):
>
> What I would simply like to do is a date diff between topic created date and today’s date to be able to say “this topic is 6 days old”

I think you could simplify that to something like:

```sql
SELECT 
    t.id AS topic_id,
    CURRENT_DATE - t.created_at::date AS days_old
FROM topics t
ORDER BY t.created_at DESC

```

There’s also a nifty `reltime$time` you can use to give relative time (though it’s more useful for intervals of less than 30 days or it gives dates instead)

```sql
SELECT 
    t.id AS topic_id,
    t.created_at AS reltime$time
FROM topics t
ORDER BY t.created_at DESC

```

---

_[View the full topic](https://meta.discourse.org/t/datediff-between-two-dates/323799)._
