On Mo, 1999-08-02 14:47:53 -0400, John <siliconghost@*stripped*>
asked regarding date arithmetic.
As Paul already wrote, the maybe easiest way is to deal with numbers
of days only ...
And here's what happened with your queries:
> mysql> SELECT ROUND(((CURRENT_DATE-"1999-07-19")/7),0);
> +------------------------------------------+
> | ROUND(((CURRENT_DATE-"1999-07-19")/7),0) |
> +------------------------------------------+
> | 2855543 |
> +------------------------------------------+
In a numerical context (as is using a minus for substraction)
date and time functions give numerical results, too.
Thus CURRENT_DATE gives the number 19990802 is this case.
Strings used in a numerical context are automatically converted into
numbers as good as possible, thus "1999-07-19" resulting in the
number 1999.
Okay: 19990802-1999 = 19988803
19988803 / 7 = 2855543.3
ROUND(2855543.3,0) = 2855543
> Also, I tried entering the exact same thing as above, but I manually
> entered today's date. This gave me 0 as an answer. I don't quite
> understand that either.
You'll guess it now: ROUND((1999-1999)/8),0) ...
Regards,
Martin
--
Martin Ramsch <m.ramsch@*stripped*> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26 E4 EC 80 58 7B 31 3A D7