Subscribe Bookmark RSS Feed

latest date within a range

schniggeldorf

Community Trekker

Joined:

Jun 23, 2011

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?

Thanks.
1 REPLY
XanGregg

Staff

Joined:

Jun 23, 2011

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.