Button that creates a new record for the next month
There is a button that creates a new record in the table for the next day
let t := this;
let oldData := last(Table1 order by Date);
let newRec := duplicate(oldData);
Table1.(Promotion := null);
Table1.(Comment := null);
newRec.(Date := Date + 1)
how to change the formula so that a record is created not for the next day, but for the beginning of the next month, for example, when you press the button, a record is created for the first day of the next month?
16 replies
-
Hi,
Can you try the following?
let x := if month(Date) = 12 then date(year(Date) + 1, 1, 1) else date(year(Date), month(Date) + 1, 1) end; newRec.(Date := x);
-
You are using this
Table1.(Promotion := null); Table1.('fine/punishment' := null); Table1.(Comment := null);
and, surely it should be this
newRec.(Promotion := null); newRec.('fine/punishment' := null); newRec.(Comment := null);
Regards John
-
Did you know this will work, even for December?
date(year(oldData.'BEG DATE'), month(oldData.'BEG DATE') + 1, 1)
Date() will roll up the year by 1 and set the month to 1 automatically. Similarly setting the day to 0 gives the last day of the month of the previous month.
Regards John
-
My full code, above probably won't work as I mean it to. The whole code can simplified to
let oldData := last('Monthly Report' order by 'BEG DATE'); let newRec := duplicate(oldData); newRec.('BEG DATE' := date(year(oldData.'BEG DATE'), month(oldData.'BEG DATE') + 1, 1)); newRec.('END DATE' := date(year(newRec.'BEG DATE'), month(newRec.'BEG DATE')+1, 0))
Content aside
- Status Answered
- 4 mths agoLast active
- 16Replies
- 78Views
-
4
Following