Missing record from multiple record creation

Missing record from multiple record creation

I have made a deluge to create multiple records based on date as below

z = input.Total_Number_of_Sessions;
x = z - 1;
y = input.Interval_between;

var = input.Start_Date_Time.daysBetween(input.End_Date_Time);
iterationString = "".leftPad(x).replaceAll(" ",",").toList().subList(0,x);
startDatevar = input.Start_Date_Time.addDay(y);

for each index i in iterationString
{
startDatevar = startDatevar.addDay(y);
res = insert into Coach_Availability
[
Coach_Name=input.Coach_Name
Start_Date_Time=startDatevar
End_Date_Time=startDatevar.addHour(1)
Date_Time=startDatevar
Added_User=zoho.loginuser
Slot_Availability="Available"
Title =  input.Title
];
}

Multiple records are created, but there is an issue in the date list
for example;
with a start_date_time of 1-Dec-2024 with interval 1 and total number of sessions 3, I expected to get 3 records with the dates 1 Dec 2024, 2 Dec 2024 and 3 Dec 2024, however I am getting records with dates 1 Dec 2024, 3 Dec 2024 and 4 Dec 2024. The record with next date after the record first date always skips a day

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now