Focal Point
[SOLVED]- Sort through date fields using IF...THEN...ELSE

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/7747074196

August 13, 2019, 02:22 PM
Kort Thompson
[SOLVED]- Sort through date fields using IF...THEN...ELSE
My task was to populate one date field out of possible four fields that has a date and use the first one that has a date. I have to proceed through the 4 date fields in a certain order until i retrieve the first one that has data. If no fields are populated, then the report should generate/display n/a.

This message has been edited. Last edited by: Kort Thompson,
August 13, 2019, 02:39 PM
MartinY
Basic If THEN ELSE in a DEFINE

But to know if the value is there or not you're the one who knows : you need to test the "missing" value assigned to the date field when it is not populated. Is it a Null (MISSING), a specific date (1900-01-01) or something else...


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
August 13, 2019, 03:09 PM
Kort Thompson
Thank you for your time. Can you give me an example of the if then else?
August 13, 2019, 03:24 PM
MartinY
You've never done programming before isn't it ?

Assuming that your date fields are in YYMD format and since you want to have N/A displayed when the date is missing, must convert the date field into a text format where N/A can be displayed.
DEFINE FILE abc
NFLD /A10 = IF FLD1 NE 'MyMissingValue' THEN FPRINT(FLD1, 'YYMD', 'A10V')
       ELSE IF FLD2 NE 'MyMissingValue' THEN FPRINT(FLD2, 'YYMD', 'A10V')
       ELSE IF FLD3 NE 'MyMissingValue' THEN FPRINT(FLD3, 'YYMD', 'A10V')
       ELSE    'N/A';
END
TABLE FILE abc
PRINT …
BY NFLD
END
-RUN



WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
August 13, 2019, 03:32 PM
Kort Thompson
Thank you, just started learning in March
August 13, 2019, 04:55 PM
Hallway
quote:
using one of the following: TCDHTDT, TCDMMDT, TCDBHDT, OR TCDLADT.


I am unfamiliar with those. Can you explain?


Hallway

 
Prod: 8202M1
Test: 8202M4
Repository:
 
OS:
 
Outputs:
 
 
 
 
August 14, 2019, 07:35 AM
Tony A
Hi Kort,

When you have found or have been provided with a solution, just edit your first post and add [SOLVED] to the begining of the post heading. Leave the original text as is so that others searching for similar questions may be able to find your post and what the solution might have been.

Also, do not change any of your original message text, unless you want to add a note to say that it's solved.

I know that many different Forums have different methods but this is what this one does Smiler


T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
August 14, 2019, 02:10 PM
MartinY
Kort,

You must NOT replace the post title by [SOLVED] but ADD the key word in the subject.
Also as stated by Tony, do not remove your first post content, otherwise I would we know to what question the answers are for ?


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
August 15, 2019, 08:27 AM
Kort Thompson
Got it...i replaced the original post and the subject line. Thanks again for the assistance.