Choose Language Hide Translation Bar
Community Trekker

latest date within a range

In my data, each subject has been observed 1-10 times. The dates of these observations are in separate columns: date1, date2... date10. How can I write a function that will choose the latest of these dates within a defined range? If I simply wanted the latest overall, it would just be a maximum function, but what if I want the latest date within 2009, for example? Can anybody see a way to get this?

0 Kudos

Re: latest date within a range

You can use sort and interpolate after putting the dates into an array. Say the dates are numbers and you're looking for the one before 100:

You need to check for i being 0 in case all the dates are below 100.
0 Kudos