michaellunsford Posted May 15, 2006 Share Posted May 15, 2006 Working on a small calendar project where there is an event date and display dates -- on and off. I have controled this with three fields in mysql: event_date, date_on, and date_off. All of the fields default to 0000-00-00, but I'd like to change that to today's date for date_on, and have date_off default to whatever is sent in event_date (which might not even be possible). One thing's for sure -- refman says I'd have to change all to the timestamp type to do anything like this (and I can only record the current timestamp).So, is all hopeless in mysql and must be hardcoded in php?idea:viewing a particular calendar page could fire something like this[code]UPDATE `table` SET `date_on` = DATE_ADD(`event_date`, INTERVAL -1 MONTH); WHERE `date_on` = '0000-00-00'[/code]will that work? Link to comment https://forums.phpfreaks.com/topic/9712-dynamic-field-default/ Share on other sites More sharing options...
fenway Posted May 16, 2006 Share Posted May 16, 2006 Unforutnately, the defaults for columns must be literals, so you can't do it the "easy way". However, the update statement you posted should be just fine (minus the extraneous semi-colon). Link to comment https://forums.phpfreaks.com/topic/9712-dynamic-field-default/#findComment-36239 Share on other sites More sharing options...
michaellunsford Posted May 16, 2006 Author Share Posted May 16, 2006 [!--quoteo(post=374283:date=May 16 2006, 09:28 AM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ May 16 2006, 09:28 AM) [snapback]374283[/snapback][/div][div class=\'quotemain\'][!--quotec--](minus the extraneous semi-colon).[/quote]oops -- old habits die hard [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] Link to comment https://forums.phpfreaks.com/topic/9712-dynamic-field-default/#findComment-36244 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.