List:General Discussion« Previous MessageNext Message »
From:Graeme B. Davis Date:March 3 2000 5:34pm
Subject:Re: date comparison
View as plain text  
I would do something like this:

mysql> select now(), (unix_timestamp(now())-unix_timestamp('2000-2-29
4:53:00'))/86400 AS result;
+---------------------+--------+
| now()               | result |
+---------------------+--------+
| 2000-03-03 12:33:52 |   3.32 |
+---------------------+--------+
1 row in set (0.00 sec)

86400 is the number of seconds in a day.

Graeme

----- Original Message -----
From: "Brett" <listmailings@stripped>
To: <mysql@stripped>
Sent: Friday, March 03, 2000 12:08 PM
Subject: date comparison


I have a table with user-inputted data in it.  It includes a datestamp.  Now
I want to (using php3) pull up a couple of fields from each record (first
and last names) and note next to the names how many days old the data are.
I am having trouble with subtracting the datestamp from a current date and
then converting to number of days (and getting anything meaningful).
Anybody know any tricks  that will allow me to do this?

Thanks, Brett
Brett Schmidt
brett@stripped


Thread
date comparisonBrett3 Mar
  • Re: date comparisonGraeme B. Davis3 Mar