I have many records for customers, I want to select the largest and smallest date, get the difference between them in days, the date format is 2004-01-01. What is the best way to go about this.
Something like this should work:
$date1 = "2004-01-01"; $date2 = "2004-02-01"; $time1 = strtotime($date1); $time2 = strtotime($date2); $time = $time2-$time1; echo $time/60/60/24;
Do you how I would select the largest and smallest dates, do I use a MIN , MAX function?
Sure, something like
SELECT MIN(date), MAX(date) FROM myTable
Should select the highest and lowest value from the field "date".
If I want to select that by Customer, do I just group the records, or do I use a foreach statement.
By the way, Thanks for all the help, have not done much with dates lately.
What does your structure look like that contains the customer/date fields?