How to get count widget to only look at tiddlers from month x to month y

82 views
Skip to first unread message

Sapphireslinger

unread,
Jan 5, 2021, 9:17:00 AM1/5/21
to TiddlyWiki
May I ask the correct way to write this?

<$count filter="[tag[Class Log - Jane Doe]has[class-date]range[July to December 2021]]"/>

I would like to count how many classes with Jane Doe were taught between July and December 2020. Each tiddler will have a "class-date" field with a date like 2020.12.01.1000 or 202012011000 or 202012011000000.

Mark S.

unread,
Jan 5, 2021, 11:03:41 AM1/5/21
to TiddlyWiki
Assuming you went with the dotted date notation, you could use:

<$vars myrange="[get[class-date]compare:text:gteq[2021.07.01]compare:text:lteq[2021.12.31]]" >
<$count filter="[tag[Class Log - Jane Doe]has[class-date]filter<myrange>]"/>
</$vars>

If you used TW's built-in date format, then there is a compare suffix for dates. 

Sapphireslinger

unread,
Jan 5, 2021, 9:57:44 PM1/5/21
to TiddlyWiki
Wow! Thank you!

May I ask what "gteq" and "1teq" stand for?

Does TW's built-in date format have a way to tell it to display as year.month.day.timesecond? Then I could have the correct display AND take advantage of TW's built-in date format.

If I use the TW's built-in date format, would the proper code for that look like this:

<$vars myrange="[get[class-date]compare:suffix:gteq[2021.07.01]compare:suffix:lteq[2021.12.31]]" >
<$count filter="[tag[Class Log - Jane Doe]has[class-date]filter<myrange>]"/>
</$vars>

Mark S.

unread,
Jan 5, 2021, 10:33:05 PM1/5/21
to TiddlyWiki
On Tuesday, January 5, 2021 at 6:57:44 PM UTC-8 Sapphireslinger wrote:
Wow! Thank you!

May I ask what "gteq" and "1teq" stand for?


gteq -- greater than or equal
lteq (not 1teq) -- less than or equal
 
Does TW's built-in date format have a way to tell it to display as year.month.day.timesecond? Then I could have the correct display AND take advantage of TW's built-in date format.


You can use the view widget with it's date format, and date template to display however you want.
 

If I use the TW's built-in date format, would the proper code for that look like this:

<$vars myrange="[get[class-date]compare:suffix:gteq[2021.07.01]compare:suffix:lteq[2021.12.31]]" >
<$count filter="[tag[Class Log - Jane Doe]has[class-date]filter<myrange>]"/>
</$vars>


Well, the variable would be like:

<$vars myrange="[get[class-date]compare:date:gteq[20210701]compare:date:lteq[20211231]]" >

Notice that "suffix" is "date", and the dots are gone.

But I haven't played with it to know if those dates are local time or UTC time (which the TW date format uses). I suspect they're UTC dates. If the dates you specify need to be UTC, then your level of happiness may depend on how close to the international timeline you live, and how late you stay up.



Eric Shulman

unread,
Jan 5, 2021, 10:38:22 PM1/5/21
to TiddlyWiki
On Tuesday, January 5, 2021 at 6:57:44 PM UTC-8 Sapphireslinger wrote:
May I ask what "gteq" and "1teq" stand for?

gteq = "greater than or equal to"
lteq = "less than or equal to"
 
Does TW's built-in date format have a way to tell it to display as year.month.day.timesecond? Then I could have the correct display AND take advantage of TW's built-in date format.

TiddlyWiki internal date format is YYYY0MM0DD0hh0mm0ss0XXX

which forms a 17-digit number where:
* YYYY = 4 digit year
* 0MM = 2 digit month (01 to 12)
* 0DD = 2 digit date (00 to 31)
* 0hh = 2 digit hour (00 to 23)
* 0mm = 2 digit minutes (00 to 59)
* 0ss = 2 digit seconds (00 to 59)
* 0XXX = 3 digit milliseconds (000 to 999)

Note that the time format does not have any punctuation, and is represented using UTC
(Universal Time Coordinated), which is essentially the same as Greenwich Mean Time (GMT)

Thus:
January 5, 2021 at 6:57:44 PM
the date of your posting in my local time zone (PST, Pacific Standard Time), is equivalent to
January 6, 2021 at 2:57:44 AM
in UTC (i.e., adjusted for 8 hours difference in timezone between PST and UTC),
and would be represented in TiddlyWiki's internal date format as:
20210106025744000
 
If I use the TW's built-in date format, would the proper code for that look like this:

<$vars myrange="[get[class-date]compare:suffix:gteq[2021.07.01]compare:suffix:lteq[2021.12.31]]" >
<$count filter="[tag[Class Log - Jane Doe]has[class-date]filter<myrange>]"/>
</$vars>

The filter definition would use:
<$vars myrange="[get[class-date]compare:date:gteq[20210701]compare:date:lteq[20211231]]" >


enjoy,
-e

Sapphireslinger

unread,
Jan 6, 2021, 7:12:57 AM1/6/21
to TiddlyWiki
Thank you Mark and Eric for all the explanations!

I think I will stick with compare:text since I live in Asia, not England ^o^
Reply all
Reply to author
Forward
0 new messages