Re: Creating Dynamic Expiration Date

From: Date: Tue, 06 Nov 2001 22:08:21 +0000
Subject: Re: Creating Dynamic Expiration Date
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-73651@lists.php.net to get a copy of this message
Thanks for the help Jack, David. I guess I'll stick to PHP! :-) __________John Monfort_________________ _+-----------------------------------+_ P E P I E D E S I G N S www.pepiedesigns.com "The world is waiting, are you ready?" -+___________________________________+- On Tue, 6 Nov 2001, David Robley wrote: > On Tue, 6 Nov 2001 17:45, Jack Dempsey wrote: > > ok, that's why: AFAIK you can't use functions like date_add in create > > clauses because they're functions, and need to be used in things like > > selects... > > What he said :-) I would think you could do this as you insert each > record, anyway (or perhaps that's what the start of this thread was all > about). > > > > > -----Original Message----- > > From: John Monfort [mailto:monfort@kahuna.sdsu.edu] > > Sent: Tuesday, November 06, 2001 2:05 AM > > To: David Robley > > Cc: php-general@lists.php.net > > Subject: Re: [PHP] Creating Dynamic Expiration Date > > > > > > > > > > David, > > > > You're right, the way you used is fine. However, I was looking for > > something different. > > > > I'm trying to use it in the following method: > > > > //my MySQL table definition > > > > CREATE TABLE members ( > > ... > > date_created timestamp(8) DEFAULT'NOW()', //This works!! > > date_expired timestamp(8) DEFAULT 'DATE_ADD(NOW(), INTERVAL 1 YEAR)' > > , ... > > ); > > > > I hope this show my troubles. > > > > Come to think of it, MySQL does not allow TRIGGERS (as far as I know). > > Is the above considered a trigger? > > > > --Is what I'm trying to do even possible? > > > > I basically want to set the result of DATE_ADD() as the > > field's DEFAULT value. > > > > > > __________John Monfort_________________ > > _+-----------------------------------+_ > > P E P I E D E S I G N S > > www.pepiedesigns.com > > "The world is waiting, are you ready?" > > -+___________________________________+- > > > > On Tue, 6 Nov 2001, David Robley wrote: > > > 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) > > -- > David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc > CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA > > You have two choices for dinner: Take it or Leave it. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#73651) next »