We are busy converting our course administration with Wappler. This goes well except for 1 point. We would like to automatically schedule all our course days.
It’s about the following.
For example, a course starts on 06-05-2019 with a course part on the same day for 10 weeks. For the course parts there is an offset of 7, 14, 21 etc. days. Now we don’t get the date field plus 7, 14, 21 etc. days.
The intention is therefore course start date plus offset of the course component is the date of the course component.
Dear Dave, So far it was also clear to us.
The problem is that we have three fields, namely: Start date, offset and course date
Start date + offset (for example 7 or 14) = course date. We need this to be able to schedule automatically.
So can you enter a series of rows into the database with that principle? Startdate - Enddate and insert each date from the start date and each day after until the end date? If so, could you give me a hint at where I should start. I was just about to start on this part of a project this morning! Ha... Any help would be much appreciated!
This is untested and off the top of my head but should work ok, hope it is what you want
If you want to add a series of rows starting at “startDate” at interval “courseInterval” until “endDate”
Send those as parameters, say $_POST.
Within a server action
Set you database connection;
define a var or session (i prefer session, saves scope issues) called courseDate
set the value of $_SESSION.courseDate to $_POST.startDate
then a while loop
while $_session.courseDate is less than endDate
set a database insert server action to set the course date to $_SESSION.couseDate (and any other data needed i.e. name,. course reference etc)
then add the courseInterval to $_SESSION.courseDate i.e.
({{$_SESSION.courseDate.dateAdd(“days”, $_POST.courseInterval)}})
The loop will continue making the inserts until the $_SESSION.courseDate becomes larger than the $_POST.endDate on which time it will stop
@Hyperbytes thanks for this. I’m trying to do something similar to @revjrblack however, I’m looking at incrementing each record insert by 15 mins as opposed to days. If I set say 13/11/19 14:00 as a start date and 13/11/19 20:00 as an end date, it simply inserts one row showing 13/11/19 14:00. If I set the end date as 14/11/19 20:00, then it will insert rows up until 23:24 on 13/11.
I’m thinking that its using the date value e.g. 13/11/19 < 14/11/19 - is there anyway I can compare times? I have tried setting DB as ‘time’ and purely entering time values on POST e.g. 08:00 as a start time and 14:00 as an end time, but it seems < does not work in this instance and nothing is inserted.