Loop Syntax Correction
Hello. I am having a bit of trouble with this for-loop, a syntax error and would love an extra pair of eyes on this,
I basically have a 'Hire Date' field, and I would like to generate a concatenated list of the number of full years since the 'Hire Date' and today. For example:
hire date:=12/22/2012;
tdy:=12/14/2022;
response:= [0,1,2,3,4,5,6,7,8,9]
Please note the zero, and also note the 10 is missing since the anniversary date has not passed the 10 year mark.
I know I am close, but I am getting a syntax error if someone could please assist.
let currentDate := now();
let hireDate := this.'Hire Date';
let years := (currentDate - hireDate) / 365;
let yearsString := "";
for i in (let i := 0; i < years; i++) do
let year := hireDate + (i * 365);
yearsString := yearsString + year + ", ";
end;
yearsString
3 replies
-
Are you using the for notion correctly? It looks wrong to me. Please check.
You might want to use the for from notation instead of the for i infor ... from ... to ... do ... end
-
Martin Mueller , I was making it way more complicated than it had to be.
Here is my outcome:
let hireDate := floor('Hire Date'); range(0, hireDate + 1)
While I am sure a loop could've achieved this too, this was probably the best solution, lol.
Content aside
- Status Answered
- 1 yr agoLast active
- 3Replies
- 59Views
-
2
Following