Hello. I have a trigger that is taking the difference of two dates (Date_Start and Date_End) and creating a new record for each one.
In Example, if Date_Start is 5/10/2021 and Date_End is 5/12/2021, three new records should be inserted into the table, one for 5/10, 5/11, and 5/12.
My problem is that my trigger is creating extra records in the table. Taking a look at the table and the trigger below may help understand the problem I am having.
Here is the trigger. Var daycount is getting the difference in days. This number should be the amount of records that will be created. The 'Date' field in the DO section receives a different date for each one in the range and is what is being used for my Calendar Datapage.
However, as you can see below, the 'daycount' or something didn't get the correct number of days, because there are more records in the table then there should be. You can see the first record has the Date Start and Date End fields that the trigger should run off of. You can also see the 3 records that should be there - the ones with a value in Date. However, there are also 4 records that do not have a Date, Date_Start, or Date_End. I am not sure where those records are coming form.
I am suspecting something is going wrong with the daycount variable or with adding 'i' to daycount. But, it all looks correct to me, so I am not sure. Another thought was maybe the SELECT statements in the daycount variable are selecting the wrong dates?
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Question
kpcollier
Hello. I have a trigger that is taking the difference of two dates (Date_Start and Date_End) and creating a new record for each one.
In Example, if Date_Start is 5/10/2021 and Date_End is 5/12/2021, three new records should be inserted into the table, one for 5/10, 5/11, and 5/12.
My problem is that my trigger is creating extra records in the table. Taking a look at the table and the trigger below may help understand the problem I am having.
Here is the trigger. Var daycount is getting the difference in days. This number should be the amount of records that will be created. The 'Date' field in the DO section receives a different date for each one in the range and is what is being used for my Calendar Datapage.
However, as you can see below, the 'daycount' or something didn't get the correct number of days, because there are more records in the table then there should be. You can see the first record has the Date Start and Date End fields that the trigger should run off of. You can also see the 3 records that should be there - the ones with a value in Date. However, there are also 4 records that do not have a Date, Date_Start, or Date_End. I am not sure where those records are coming form.
I am suspecting something is going wrong with the daycount variable or with adding 'i' to daycount. But, it all looks correct to me, so I am not sure. Another thought was maybe the SELECT statements in the daycount variable are selecting the wrong dates?
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.