Hello everyone,
I have a database like this (this is a summary here):

This database comes from a script which works well so far, however the last column would allow calculating a last duration different from the others.
The values in this last column represent OPs which correspond to objects.
For example for the 1st line: the value 60 corresponds to the object 2041, we would need a formula allowing duration 2041 = end date 2041 - start date 2041 and so on for each line.
When the value is equal to 0 we could assign the value 0 to duration 2041.
And so on..
I started with the script below:
Names Default To Here(1);
dt = current data table();
If( !Is Missing(:"CIC-2"n),
For Each Row(
idx = dt[row(), :"CIC-2"n]
dt[idx, durée[idx]] = dt[idx, date fin[idx]] - dt[idx, date début[idx]];
),
0
);