Wednesday, 21 January 2015

Quick Tip - @Formula Weekdays

Currently I am working on a classic Notes database, a Leave Registration database.
The question was to only include weekdays in a new request even if the request contained a weekend.
I solved this by using the following @Formula I came across:

Weekday := "2" : "3" : "4" : "5":"6";
R := @TextToTime(@Explode(@TextToTime(@Text(DateField1) + " - " + @Text(DateField2))));
D := @Replace(@Text(@Weekday(R)); Weekday; "X" + Weekday);
W := @Trim(@Right(@Left(@Explode("<" + @Implode(D + "=" + @Text(R); "<") + "<"; "X"); "<"); "="));

Based on the request an XML file is generated which is used as an import file for a different application. In the example below a request was made in which a weekend is contained.

The generated XML file includes only the Friday and Monday based on the @Formula.

Not very complicated but it works. Perhaps it may still be of some help to someone.

No comments:

Post a Comment