• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

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?
0
barbotte
Asked:
barbotte
1 Solution
 
Sjef BosmanGroupware ConsultantCommented:
maxy:= @adjust(@Today; 100;0;0;0;0;0);

mindate:= @subset(
    @sort(
        @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);

mindate

Unfortunately, works only in R6...
0
 
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.
0
 
barbotteAuthor Commented:
sjef_bosman , What does the first line mean?

Cos the dates in the 6 fields could be in 2008 or so!
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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

eg:

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

~Hemanth
0
 
barbotteAuthor Commented:
Ok, sjef_bosman  solution works fine, thank you!
0
 
qwaleteeCommented:
You CAN get OK performance out of the @Today by using an odl textttime of "Today" trick.
0
 
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...
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now