RE: [PHP-DB] Difference between 2 dates.. thoughts?

2002-11-13 Thread Jason Vincent
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).

Regards,

J


-Original Message-
From: Aaron Wolski [mailto:aaronjw;martekbiz.com] 
Sent: Wednesday, November 13, 2002 11:33 AM
To: [EMAIL PROTECTED]
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!
 
Aaron



RE: [PHP-DB] Difference between 2 dates.. thoughts?

2002-11-13 Thread Aaron Wolski
Hi There,

Well the first and last record of the results.

So if 1000 records were found... then record #1 and then record #1000 -
perform data calculation between those 2 records (how many days does
this query span).

Know what I am trying to say?

Sorry if its not clear.

Aaron

-Original Message-
From: Jason Vincent [mailto:jayv;nortelnetworks.com] 
Sent: November 13, 2002 12:24 PM
To: Aaron Wolski; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Difference between 2 dates.. thoughts?

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).

Regards,

J


-Original Message-
From: Aaron Wolski [mailto:aaronjw;martekbiz.com] 
Sent: Wednesday, November 13, 2002 11:33 AM
To: [EMAIL PROTECTED]
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!
 
Aaron



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Difference between 2 dates.. thoughts?

2002-11-13 Thread Jason Vincent
Test whether min() and max() work on date fields - never tried it.  Or check
the documentation on date and time functions for your database - they may
have something that does this.

If not, you could just do an order by date ascending and grab only the first
record, then an order by date descending and grab the first record of that.
Then you would need to use some date function (or php date module) to find
the span.  If you are using mysql, check out the INTERVAL function.

Regards,

J


-Original Message-
From: Aaron Wolski [mailto:aaronjw;martekbiz.com] 
Sent: Wednesday, November 13, 2002 12:27 PM
To: Vincent, Jason [BRAM:1334:EXCH]; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Difference between 2 dates.. thoughts?


Hi There,

Well the first and last record of the results.

So if 1000 records were found... then record #1 and then record #1000 -
perform data calculation between those 2 records (how many days does this
query span).

Know what I am trying to say?

Sorry if its not clear.

Aaron

-Original Message-
From: Jason Vincent [mailto:jayv;nortelnetworks.com] 
Sent: November 13, 2002 12:24 PM
To: Aaron Wolski; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Difference between 2 dates.. thoughts?

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).

Regards,

J


-Original Message-
From: Aaron Wolski [mailto:aaronjw;martekbiz.com] 
Sent: Wednesday, November 13, 2002 11:33 AM
To: [EMAIL PROTECTED]
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!
 
Aaron





RE: [PHP-DB] Difference between 2 dates.. thoughts?

2002-11-13 Thread Aaron Wolski
Ok,
 
Thanks for your input. I know very little about how to manipulate MySQL
so this out to be fun and very slow going :-(
 
Thanks!
 
Aaron
 
-Original Message-
From: Jason Vincent [mailto:jayv;nortelnetworks.com] 
Sent: November 13, 2002 12:34 PM
To: Aaron Wolski; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Difference between 2 dates.. thoughts?
 
Test whether min() and max() work on date fields - never tried it.  Or
check the documentation on date and time functions for your database -
they may have something that does this.
If not, you could just do an order by date ascending and grab only the
first record, then an order by date descending and grab the first record
of that.  Then you would need to use some date function (or php date
module) to find the span.  If you are using mysql, check out the
INTERVAL function.
Regards, 
J 
 
-Original Message- 
From: Aaron Wolski [mailto:aaronjw;martekbiz.com] 
Sent: Wednesday, November 13, 2002 12:27 PM 
To: Vincent, Jason [BRAM:1334:EXCH]; [EMAIL PROTECTED] 
Subject: RE: [PHP-DB] Difference between 2 dates.. thoughts? 
 
Hi There, 
Well the first and last record of the results. 
So if 1000 records were found... then record #1 and then record #1000 -
perform data calculation between those 2 records (how many days does
this query span).
Know what I am trying to say? 
Sorry if its not clear. 
Aaron 
-Original Message- 
From: Jason Vincent [mailto:jayv;nortelnetworks.com] 
Sent: November 13, 2002 12:24 PM 
To: Aaron Wolski; [EMAIL PROTECTED] 
Subject: RE: [PHP-DB] Difference between 2 dates.. thoughts? 
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).
Regards, 
J 
 
-Original Message- 
From: Aaron Wolski [mailto:aaronjw;martekbiz.com] 
Sent: Wednesday, November 13, 2002 11:33 AM 
To: [EMAIL PROTECTED] 
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! 
  
Aaron