Re: default date + 180 days

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • h.stroph

    Re: default date + 180 days

    "Gordon Burditt" <gordonb.xrkjr@ burditt.orgwrot e in message
    news:oPKdna2Rip 5ryDHVnZ2dnUVZ_ gqdnZ2d@posted. internetamerica ...

    [cross-posted to comp.lang.php for assistance]
    I'd like to set the default for a date column "reserve_du e" to be another
    date field "reserve_servic ed" plus 180 days, so that when the
    "reserve_servic ed" field is changed, the "reserve_du e" 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_service d plus 180 days?
    No, it is a federally mandated time interval, and we need to know the
    reserve_due = reserve_service d + 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_service d exists, and reserve_service d 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_service d 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_servic ed'] = array(
    'name' ='Reserve serviced',
    'select' ='T',
    'maxlen' =10,
    'sort' =true
    );
    $opts['fdd']['reserve_due'] = array(
    'name' ='Reserve due',
    'select' ='T',
    'maxlen' =10,
    'sort' =true
    );
    ....


Working...