Countdown to month/day issue

I asked chatgpt to generate KWGT code to display the number of days remaining until a given date, independent of the year. For example: if it is 10 days until February 16th, each day that passes would display 9, 8, 7, 6 etc. And on February 16th it would display 365.
The code generated by chatgpt was:

$if(df(MMdd)>0216, (365-tf(df(yyyy)+1+“-02-16”, “D”))+tf(df(yyyy)+“-02-16”, “D”), tf(df(yyyy)+“-02-16”, “D”)-tf(df(yyyy), “D”))$ days until February 16th

The result is this (and it does not change with each passing day):

365 until February 16th

It did correctly generate code that works for the current year: $tf(10M08d,D)$ days until October 8th

Displays: 33 days until October 8th

But the same code with a date thats passed for the current year and wont occur until the following year is incorrect. For example, using the same code with February 16th… $tf(02M16d,D)$ days untul February 16th…returns this:

-199 days until February 16th

Can someone please help or advise… thanks!

Kudos GPT!! Nice to know :slight_smile:

This is because by default Kustom assumes YEAR is the current one, you can change year this way:


Or if you always want to use next year you can “add one year” by adding “a1y” at the end, so this:


Will also return next year 16 February

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