Re: php3 MySQL------ is it necessary to convert all dates if I want to calculate ?
| From: | David Robley | Date: | Wed, 18 Oct 2000 02:36:56 +0000 |
| Subject: | Re: php3 MySQL------ is it necessary to convert all dates if I want to calculate ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-20762@lists.php.net to get a copy of this message | ||
On Wed, 18 Oct 2000, Joachim Ritzer wrote:
> hello everybody,
>
> maybe someone had the same problem before.
> Is it necessary to convert all dates first from dd/mm/yy to yy/mm/dd and
> again in MySQL from yy-mm-dd to a number (see example below), if i want to
> calculate?
>
> mysql> select TO_DAYS(9505); -> 733364
> mysql> select TO_DAYS('1997-10-07); -> 729669
>
> What I´m looking for is a function, that selects the arrival-date and
> departure-date from a database and calculates automatically the days
> between.
>
> Thanks for your help in advance and have a nice week,
>
> best regards joachim.
You could use MySQL to do something like
SELECT (TO_DAYS(departure) - TO_DAYS(arrival)) as difference FROM table
WHERE ....
depending on how your date values are stored; you might have to use
FROM_UNIXTIME to get ymd type date format.
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA