Switch/case instead of If

This question is based on Q_21139033

Let's say I have 6 different "date/time" fields.

Some of them could be left blank.

In a view, I'd like a specific column to show the earliest date among the 6 fields...

So, is there a way to do a Switch/case thing in Lotus Notes??  Or should I make a big IF statement?
Who is Participating?
Sjef BosmanConnect With a Mentor Groupware ConsultantCommented:
maxy:= @adjust(@Today; 100;0;0;0;0;0);

mindate:= @subset(
        @if(@istime(field1); field1; maxy):
        @if(@istime(field2); field2; maxy):
        @if(@istime(field3); field3; maxy):
        @if(@istime(field4); field4; maxy):
        @if(@istime(field5); field5; maxy):
        @if(@istime(field6); field6; maxy)
    ); 1);


Unfortunately, works only in R6...
Sjef BosmanGroupware ConsultantCommented:
But don't EVER do this in a view column, for it will make the view unnecessarily slow. It's better to add a field that does this computation when the document is saved.
barbotteAuthor Commented:
sjef_bosman , What does the first line mean?

Cos the dates in the 6 fields could be in 2008 or so!
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

barbotteAuthor Commented:
and...  What should I do if the database already have records in it?
Use @Sort if you are using R6


list := @trim(f1:f2:f3:f4:f5:f6);
Sort(list; [Descending])

barbotteAuthor Commented:
Ok, sjef_bosman  solution works fine, thank you!
You CAN get OK performance out of the @Today by using an odl textttime of "Today" trick.
Sjef BosmanGroupware ConsultantCommented:
The first line creates a vraiable with a date 100 years from now, assuming you're not going over it. Astronomers do...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.