You should be able to do this at the database level - of course you never
said what database that is.

Regardless, check your database documentation for the max() and min()
functions - never used these on date but they might work - do you always
want the first record and the last record in the database?  Or do you mean
the first and last record of the record set?  If you always want the first
record inserted and the last record inserted, than use max() and min() in
the unique database key (the unique record number) assuming you have one and
that they are sequential.

Then check for any date functions that might be able to tell the days
elapsed between to dates (in mySQL you might look at the interval function).



-----Original Message-----
From: Aaron Wolski [mailto:aaronjw@;] 
Sent: Wednesday, November 13, 2002 11:33 AM
Subject: [PHP-DB] Difference between 2 dates.. thoughts?

Hi All,
First off I have a query like this:
SELECT dateinserted FROM SiteTrackingTable;
Now. in this query any number of results could be returned 10 or 1000, etc.
Is it possible to take the dateinserted value from the first record and then
from the last record and perform some calculation to get the number of days
the record spans?
Haven't done something like this before and don't have a clue where to
start. Date sorting,etc I can do just don't know about this one.
Thanks for your help!

Reply via email to