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
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?
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.
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.
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
```