By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,746 Members | 1,924 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,746 IT Pros & Developers. It's quick & easy.

Re: default date + 180 days

P: n/a
"Gordon Burditt" <go***********@burditt.orgwrote in message
news:oP******************************@posted.inter netamerica...

[cross-posted to comp.lang.php for assistance]
I'd like to set the default for a date column "reserve_due" to be another
date field "reserve_serviced" plus 180 days, so that when the
"reserve_serviced" field is changed, the "reserve_due" is also updated
according to the date+180 formula:

It's generally a bad idea to put redundant information into a table.
Is there any situation, default or non-default, where reserve_due is
NOT reserve_serviced plus 180 days?
No, it is a federally mandated time interval, and we need to know the
reserve_due = reserve_serviced + 180 days at any time when examing the table
with any arbitrary 3rd-party tools. While it might be considered redundant,
it is the main reason why reserve_serviced exists, and reserve_serviced can
change at any time before the 180-day limit.

Someone might be using Toad, MS-Access (?), a database export or some other
tool to examine the table, primarily to see the reserve_due date field for
each of the hundreds of pieces of equipment in the table or to change the
reserve_serviced date field when they have serviced a particular piece of
equipment.
I'd suggest dropping the reserve_due field entirely, and when you
get data from the table, do something like:

select *, adddate(reserve_serviced, 180) as reserve_due from
gear_inventory;
if you just want to have MySQL do the date math.
Yes, thank you, we could customize a query like that and attach it to a
structure generated by phpmyedit-generated scripts, but how would we state
that in the php script which is currently recalling the reserve_due field
(which will be deleted per your advice if we can get this to work), the
relevant portion of which follows? We'd like to have the mysql-calculated
reserve_due value appear at the same place in the output:

....
$opts['fdd']['reserve_serviced'] = array(
'name' ='Reserve serviced',
'select' ='T',
'maxlen' =10,
'sort' =true
);
$opts['fdd']['reserve_due'] = array(
'name' ='Reserve due',
'select' ='T',
'maxlen' =10,
'sort' =true
);
....
Aug 20 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.