Extract list of days contained in a data range

Hi,

in my app i’m facing a problem with dates and date ranges.

Basically, what i’m looking for is a way to extract the list of each single day contained in a data range; I’m working on it but still haven’t found a solution (there is a super manual way, by creatinge each day one by one, but is not an efficient solution).

Main use case: the user inserts a starting date and an end date. I would like the system to create a row in the database for each day contained in that range of dates.

I’m exploring some plugins at the moment, but i’m wondering if it is doable without using them.

Thank you so much for your help!
Andrea

I’m not sure if I do not understand the use of row in database properly or not, but my assumption is you are just wanting to save the values in the database. Since there would not be a known number of possible dates (because no known restrictions on start or end dates to know how many dates will be returned by any users interaction with the system), you’d likely want to store the values as a list of something. Optimally that list would be of date objects, so a data field of type date that is a list, needs to be in your database, on a data type that you need this information saved to.

I believe there is a free plugin called List of Dates that potentially can be used for this use case.

Start Date is the Start Date of the Range. Interval Type is Day. Interval is 1. The Number of dates is the dynamic expression of Range Start Date minus Range End Date formatted as days (you might need an additional operator like floor or ceiling to get it right).

Then save the the data field that is a list of dates, the value from the plugin element.

This topic was automatically closed after 70 days. New replies are no longer allowed.