Formatting Date / Day issue

I am trying to work with the date / day formatting to generate a query. The issue that i am having is that for some reason, the day from the date is not matching up.

I have a query that is taking a date_start and adding up 1 day for a total of 14 days.
A few of the dates and days line up, but there are couple that don’t see to work correctly

but you can see from the results that the insert data is not correct
notice how 7-21 and 7-22 the day is still Friday

I am pulling the dddd format from the same date, but its not pulling the day correctly. Any thoughts on why that is occuring?

even the most simply query duplicates the dates and days. It should just go through 14 days and add the date and days, but its duplicating certain dates and getting the day of the week wrong.

Is there any chance, that wappler editor is calling the action and inserting some value in some open file?

i’m not exactly sure what you mean, but i do know that there are no other processes for this running from our end. I have even tried to page in Incognito mode and it produces the same result. I just can’t get it to run through the dates / days of the week without a duplication or issue.

What is the output you see in a dev panel?

here is that is produced, but its only the last part of the While loop. I don’t know a way to see each and every step

https://atgenius.com/appointment_scheduler/appointment_scheduler.asp

This is what you want to insert in your db?

correct, but also i want to be able to have the date converted to a day of the week

so one field is the date…and the other field will be the day of the week. I am using the Date Formatter for this with the dddd format.

what did you do to get the repeat step to run for this? are you running this on the client side or server side?

this is kinda what i have been following:

https://community.wappler.io/t/generating-or-adding-to-a-list-of-dates-in-a-table/16507

I set a repeat step with the value “14”

Under the repeat->exec->setvalue: add an insert step and edit the value:

BTW: I’m receiving UTC timezone and not local timezone, in Argentina is 10pm, but the values are 1 am, so the api is inserting that. If you search “utc” on this forum you’ll see is a frecuent topic :slight_smile: .

thank you so much for this. I am going to alter my setup and see if this way will work better!!

I will report back tomorrow.

It was a pleasure
BTW, what i was refering here for the duplicated thing:

(Just a tip)
If you have an open file in wappler which contents your server connect action (client side), then:
the Wappler Editor (Software) will call the action everytime you reload the page (like a browser will do), so maybe you’re calling from the api, but also :eyes: wappler stills calling it in the design panel.
Otherwise i don’t know why you’re having duplicated entrys.

Okay, something is very screwy here…or its just messing with me.

I just tried to create exactly what you had above…and it repeats the same date for me.
https://atgenius.com/appointment_scheduler/appointment_scheduler.asp

this will always repeat the same date. As the input date is always the same date_start and you always add 1 day to it. You want to do something like:

start_date.dateAdd('days', $index+1)

instead of

start_date.dateAdd('days', 1)

hi Teodor, shouldn’t the repeat function work within itself and keep adding one day to the date until it completes? It seemed to have worked for franse above.

Your way did indeed work (thank you!), but i am just trying to figure out the logic on why my original setup didn’t process the same.

Same question, im using php, does it work diferent?

Unfortunately Teodor, i am still having an issue with implementation. I am now trying to integrate this with the calendar function to pull info, but it still does not seem to be handling the Date formatting correctly

In the calendar, i am clicking on a specific day.
The calendar then opens up a module to display the date and then available appointments, but as you can see, its not converting the date to the correct day. Its one day off.

Here is how i have it setup, but i can’t seem to get it to display the correct day

do you see anything wrong that is causing this? I appreciate your help.

Maybe it’s related to this:

yes, you may be right.

as a workaround right now, i am just adding 1 day to the day formatter to have it match what the actual day is. It seems to work. The only issue i guess would be if there is something else that displays for users in other time zones.

The repeat has its own scope, setting a variable inside does not change the variable on the parent scope unless you use global variables. This is the expected behavior and not a bug.

The date_start in the expression does not find a variable in the current repeat scope so it gets the value from the parent scope and that happens with each loop. So every item will be the same date_start + 1. To make it overwrite the global date_start and update it in each loop set the Global Name property also to date_start, then you get the same behavior as @franse.