Dataview deadline + time Coutdown

Hello, I want to consult because I have this table of dates and countdown that I made based on a code from a forum thread.

TABLE deadline - date(today) AS Countdown
FROM "✅To Do/🎯Freelance"
WHERE deadline >= date(today)
SORT (deadline) ASC

Each individual note has the following

deadline: 2023-05-19

So far it works perfect.

Now I would like to add HH:mm (avoid seconds)

try this on individual notes


deadline: 2023-05-19T14:50:00

but the result is that the table gives me this result

“Arlequin - Opentoonz 2 weeks, 6 days, 13 hours, 22 minutes” that is, it does not perform the countdown but only sets the time that I set.

Try this code on the table:

TABLE deadline.format("YYYY-MM-DD HH:mm:ss") as deadline, deadline - date(today) AS Countdown
FROM "✅To Do/🎯Freelance"
WHERE deadline >= date(today)
SORT (deadline) ASC

but it didn’t work for me either, it gives me null

Dataview: Every row during final data extraction failed with an error; first 13:

        -Cannot call type 'null' as a function

-Cannot call type ‘null’ as a function
-Cannot call type ‘null’ as a function

How could I solve it? Thanks

What do you mean when saying it doesn’t give you the countdown. Today is May 4th, and in 2 weeks and 6 days we’re at May 20th, which I reckon is just a timezone issue. So what did you expect it to output?

image

image

The date in days is fine. But in hours, it only puts the time that I put on it. If I put “15:00” in the table it will show “15 hours 30 minutes” If I change to 20:43 it will put “20 hours 43 minutes”

***In the first message I put an hour at the beginning and another in the result of the table, because I got confused haha.

Try using date(now) instead of date(today). The latter will only give you the actual date, whilst the former will also give you the hour and minutes.

Just the date: `= date(today)`
With hours and minutes: `= date(now) `

Which displays as:
image

See Dataview literals’ documentation for a little more information on what’s available.

I understand now I run the format.


deadline: 2023-06-24T15:30

With this I improve a lot.
There is a way to put it only in minutes. Because here it returns me seconds and milliseconds. Otherwise I’ll look in the documentation.

Thanks a lot!

image

I’ve not worked a whole lot with durations, so I’m not sure how to limit the output of it. I know you can pull out the various bits and pieces using stuff like .hours or .days, but not sure how to “remove” the seconds and milliseconds parts. Or maybe we can pull out the minutes, round it, and transform it back into a duration?

Try the following on for size:

```dataview
TABLE deadline.format("YYYY-MM-DD HH:mm") as deadline, Countdown
FROM "✅To Do/🎯Freelance"
FLATTEN deadline - date(now) AS theDuration
FLATTEN dur(string(round(theDuration.minutes)) + " minutes") as Countdown
WHERE deadline >= date(now)
SORT (deadline) ASC
```

Here is some similar trickery condensed into one-liners:

Limit to hours: `= dur(string(round((date(2023-05-23T15) - date(now)).hours)) + " hours") `

Just the hours: `= dur(string(round((date(2023-05-23T15) - date(now)).hours)) + " hours").hours `

Now for some reason they both work haha.

TABLE deadline - date(today) AS Countdown, platform
FROM "✅ To Do/🎯Freelance"
WHERE deadline >= date(today)
SORT (deadline) ASC
TABLE countdown , platform
FROM "✅ To Do/🎯Freelance"
FLATTEN deadline - date(now) AS theDuration
FLATTEN dur(string(round(theDuration.minutes)) + " minutes") AS countdown
WHERE deadline >= date(today)
SORT (deadline) ASC

Now it does its job perfectly. Then I’ll see how to change the

1 month, 2 weeks, 5 days, 18 hours, 28 minutes

in 1M 2W 5d 18h ​​28m

Or something similar, but it is no longer necessary.
Very Thanks.

1 Like

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