471,066 Members | 1,252 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,066 software developers and data experts.

Re: default date + 180 days

"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
0 955

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

16 posts views Thread by sandy | last post: by
4 posts views Thread by Richard Hollenbeck | last post: by
1 post views Thread by Wayne | last post: by
29 posts views Thread by james | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.