Version: MySQL 4.0.11-gamma-nt
OS: Windows NT4 Server
I have a test table like this:
CREATE TABLE test (
created date NOT NULL default '0000-00-00',
duration smallint(5) unsigned NOT NULL default '0'
) TYPE=MyISAM;
INSERT INTO test VALUES("2003-01-01", "365");
INSERT INTO test VALUES("2003-01-01", "0");
I'd like to compute created+duration-CURDATE(), ie. the remaining days
of the item (result <0 means item expired):
select to_days(created) + duration as expiration,
to_days(curdate()) as current,
to_days(created) + duration - to_days(curdate()) as remaining
from test;
With the following result:
expiration, current, remaining Notes:
731946, 731638, 308 Ok, 308 days remain until item expires
731581, 731638, 0 Mh, I'd expect -57, ie. item expired,
what's your guess!?
Seems like A+B works, A+B-C doesn't...
Cheers,
.SMK.
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php