Finding the Latest Date from Multiple Date Fields The following is a programming statement for transferring the latest date from several date fields to one search date field. For example, if your business application is a sales tracking database of all customer orders by date, you may need to know when a customer's last purchase was made. If each order date is recorded in a different field, a search for the latest date in any of the fields would not give you the latest date for that customer order. What you need to be able to do is compare all the dates on a customer order, find the latest date and put it in another field. The following programming statement will perform this function. You can also search for the highest or lowest number from multiple numeric fields. The earliest date can also be retrieved using this program statement, by changing @MAX to @MIN. From the Q&A Main Menu choose: File Design (choose your filename.dtf) Customize Program Form Type the following in the appropriate date fields: Date1: >#1:#5=@MAX (#1..#3) Date2: >#2:#5=@MAX (#1..#3) Date3: >#3:#5=@MAX (#1..#3) Latest Date: #5 (This will be your search field) To use this programming statement for more date fields, simply increase the underlined numbers by one for each additional date field, and increase #3 in the range (#1..#3) to the largest number of date fields you will be using. Q & A Application Note Rev. 6/92 #2202 Page 1 of 1