Annually Change Query Dynamically

What’s the best way to change a query to advance to a certain date as mentioned below?

  1. Display the current query results, i.e., June 15, 2022.
  2. Set a date ‘trigger’ to automatically display that data for one calendar year then change the query on June 15, 2023 to hide previous 2022 data and display the new 2023 data.

I guess you can achieve what you want by building a condition into your server action.

If current datetime > june 15, 2023, then query with a filter that gives you only 2023 data.

Is that what you’re looking for? Perhaps more context about the end goal helps as it seems like an uncommon thing to want to do, which makes me think there are alternative ways to reach the same end goal

Thank you Karh. Yeah, it is uncommon. However, this group has annual reports that begin on July 15th and end on July 14th following year.

So the query that I’m using needs to show the previous 12 months until the next year on July 15th. They gather requests from their clients from the 15th till December of that year. After December 31 the requests are sent out and the process is restarted again.

What’s stopping you from setting up an input field that allows the user to select the year.
Then after that you do a query based on that time input. Something like this: Filter a Server Connect Query by Date Range Picker

1 Like

I’ll give it a go. Thanks!

The cutoff date is June 1 of each year.

  1. All previous year’s entries will be archived without a condition.
  2. All new entries for the next year will be listed that is queried with: school_year < {{NOW.formatDate(‘yyyy’)+’-06-01’}}.
1 Like