View Single Post
Old 01-09-2022, 07:09 AM   #276
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,453
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
I've got it.

Code:
program:

arguments(date, colourA, colourB, colourC);
now = format_date(today(), 'yyyy-MM-dd');

		if days_between(now,date) <= '1' then colourA
		elif days_between(now,date) <= '7' then colourB
		elif days_between(now,date) <= '14' then colourC fi
As you know that days_between() returns a number, I suggest you use numeric comparisons. That will avoid problems caused by the order of the tests. For example, using string comparisons '14' is less than '7'.

Try this:
Code:
program:

arguments(date, colourA, colourB, colourC);
		now = format_date(today(), 'yyyy-MM-dd');
		days = days_between(now,date);

		if days <=# 1 then colourA
		elif days <=# 7 then colourB
		elif days <=# 14 then colourC fi
chaley is offline   Reply With Quote