Display number of days passed since last modification

I see currently no way in Bases to display an operation on dates/time as a number (of days)

I’ve tried:

  • today() - file.mtime.date()
  • now() - file.mtime
  • file.mtime.relative()

but the result is always a number of year, month, days, minutes, second…
I would like to consistently display the number of days past as a… number

what I get in bases

what I use to get in dataview (using (date(today) - file.mday).days )

Trying to solve the same problem, and found the solution: (today()-file.mtime).days.round(). Gives the total number of days difference.

I actually use (today()-file.ctime).days.round() + " days (" + file.ctime.relative() +")" for the best of both worlds :slight_smile: (note this is created time, not modified)

1 Like

Oh yes! That it, thank you so much!

I just noticed that using now() is more precise that today() (especially relevant for notes modified in the last hours/days). So:

(now()-file.mtime).days.round()
1 Like

Thx for the info.

I came up with something for now that works like this:

Display
“Months Weeks Days” (0 Months, Weeks, Days will be removed)
Today, future and past Differentiation
So Like:
→ 2 Months 2 Days
← 3 Weeks 1 Days
etc.

Havent implemented Years yet.
Its close enough taking into account an average of days in month considering leap years etc.

Here’s the formula. Just replace PLACEHOLDER with your date property.

if(PLACEHOLDER.isEmpty(), "", if((today() - PLACEHOLDER).months > 0, "<- ", if((today() - PLACEHOLDER).months == 0, "Today", "-> ")) + if(((today() - PLACEHOLDER).months.abs().floor()) == 0, "", (today() - PLACEHOLDER).months.abs().floor() + " months ") + if(((((today() - PLACEHOLDER).months.abs()) - ((today() - PLACEHOLDER).months).abs().floor())  * 4.348125).floor() == 0, "", ((((today() - PLACEHOLDER).months.abs()) - ((today() - PLACEHOLDER).months).abs().floor())  * 4.348125).floor() + " weeks ") + if(((((((today() - PLACEHOLDER).months).abs() - ((today() - PLACEHOLDER).months).abs().floor())  * 4.348125) - ((((today() - PLACEHOLDER).months).abs() - ((today() - PLACEHOLDER).months).abs().floor())  * 4.348125).floor()) * 7).round() == 0, "", ((((((today() - PLACEHOLDER).months).abs() - ((today() - PLACEHOLDER).months).abs().floor())  * 4.348125) - ((((today() - PLACEHOLDER).months).abs() - ((today() - PLACEHOLDER).months).abs().floor())  * 4.348125).floor()) * 7).round() + " days"))

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.