Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Selecting earliest date

I have a MSSQL view that I have pulled into Crystal Reports.

The table looks something like this:

PatId SpecDt_1 SpecDt_2 SpecDt_3 SpecDt_4 SpecDt_5

PSN10812085TN01 1/9/2008 1/9/2008 1/9/2008 1/21/2008 1/5/2008

PSN10815697TN01 1/14/2008 1/7/2008 2/2/2008 1/14/2008 2/11/2008

PSN10815041TN01 1/15/2008 3/1/2008 2/22/2008 3/1/2008 1/14/2008

PSN10817602TN01 1/10/2008 1/10/2008 2/1/2008 1/15/2008 1/16/2008

PSN10820762TN01 1/24/2008 1/25/2008 1/23/2008 1/1/2008 2/8/2008

For each patient (PatId), I am trying to select the earliest event date (SpecDt_#). As you can see there are 5 event dates for each patient. I have tried using the minimum function, but it will only look at 2 dates for comparison. Any suggestions would be greatly appreciated.

I have had to learn CR on my own, so if you respond please take that into consideration.

replied

Try this formula that returns earliest date for each patID

dateTimeVar array arr;
redim preserve arr[4];
arr:=makearray({SpecDt_1},{SpecDt_2},{SpecDt_3},{SpecDt_4},{SpecDt_5});
Minimum(arr)

Regards,

Raghavendra

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question