Snippet to output term based on date range

I am trying to make a snippet that enters "Spring 2024", "Summer 2024", and "Fall 2024" based on if today is within the range of that specific term's dates.

The rules I need to follow:
The text "Spring 2024" is output if today is between April 1, 2024 and June 15, 2024. If the date is between or equal to June 16, 2024 and August 21, 2024 then the text output is "Summer 2024". Otherwise, if the date is between or equal to August 22, 2024 and December 14, 2024 then the text output should be "Fall 2024".

I tried to create this snippet, but was unsuccessful. Here is my attempt:

{note}{time: MM-DD}{endnote}{if: {time: MM-DD} >= {time: 04-01} AND {time: MM-DD} <= {time: 06-23}}Spring 2024{elseif: {time: MM-DD} >= {time: 06-24} AND {time: MM-DD} <= {time: 09-21}}Summer 2024{elseif: {time: MM-DD} >= {time: 09-30} AND {time: MM-DD} <= {time: 12-31}}Fall 2024{endif}

Thank you for any help or guidance.

Answered my own question. Here is the answer:

{note}Format DD/MM/YY
{SpringStart="01/04/24"}Start date: {=SpringStart}
{SpringEnd="15/06/24"}End date: {=SpringEnd}
{SummerStart="16/06/24"}Start date: {=SummerStart}
{SummerEnd="29/09/24"}End date: {=SummerEnd}
{FallStart="30/09/24"}Start date: {=FallStart}
{FallEnd="14/12/24"}End date: {=FallEnd}
Today's date is {time: MMMM Do, YYYY}{endnote: trim=right}
{if: {time: X} >= {time: X; at={=SpringStart}; pattern=DD/MM/YY} AND {time: X} <= {time: X; at={=SpringEnd}; pattern=DD/MM/YY}}Spring 2024{elseif: {time: X} >= {time: X; at={=SummerStart}; pattern=DD/MM/YY} AND {time: X} <= {time: X; at={=SummerEnd}; pattern=DD/MM/YY}}Summer 2024{elseif: {time: X} >= {time: X; at={=FallStart}; pattern=DD/MM/YY} AND {time: X} <= {time: X; at={=FallEnd}; pattern=DD/MM/YY}}Fall 2024{endif}

1 Like