Re: Creating Dynamic Expiration Date

From: Date: Tue, 06 Nov 2001 05:05:30 +0000
Subject: Re: Creating Dynamic Expiration Date
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-73546@lists.php.net to get a copy of this message
On Tue, 6 Nov 2001 14:19, John Monfort wrote: > Hello everyone, > > I'm developing a database which holds a START and EXPIRATION date. > I would like to have MySQL generate the expiration date automatically > and was wondering if that could be done. > > I'm using the MySQL NOW() to add today's date as the START date. > The expiration date is one year from the start date. I read about the > mysql DATE_ADD function, in which can be used as > > DATE_ADD("2001-11-05 13:00:00", INTERVAL 2 MONTHS) > > Is there a way to use it as DATE_ADD( NOW(), INTERVAL 1 YEAR), to > automatically add one year to today's date. > > I tried the above, but it did not work. The start and expiration date > still come out as the current date( the result of NOW() ). > > btw, both START and EXPIRATION are of the data type TIMESTAMP (8). > > Please help. > > How do I (dynamically) add one year to the current date? > > i.e. add_date(CURDATE(), INTERVAL 1 YEAR) > Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 633 to server version: 3.23.12c-alpha Type 'help' for help. mysql> select date_add(now(),INTERVAL 1 year); +---------------------------------+ | date_add(now(),INTERVAL 1 year) | +---------------------------------+ | 2002-11-06 15:33:12 | +---------------------------------+ 1 row in set (0.05 sec) Seems to work for me. -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA Budget: A method for going broke methodically.

« previous php.general (#73546) next »