This topic is locked

Date plus 30 days

9/7/2010 9:58:09 PM
PHPRunner General questions
A
ashumak author

Hi,
I have a field (date_opened) and another field (date_archived)...
date_opened is read only, with the default of Now()
What I need, is a way for date_archived to be set the same way as the current day plus 30 days...
Any help appreciated....
Alan

R
rod 9/7/2010



Hi,
I have a field (date_opened) and another field (date_archived)...
date_opened is read only, with the default of Now()
What I need, is a way for date_archived to be set the same way as the current day plus 30 days...
Any help appreciated....
Alan


Here is one way...In PHP



<?php

echo date('Y-m-d H:i:s')."<br/>";

echo date('Y-m-d H:i:s', mktime(date('H'),date('i'),date('s'), date('m'),date('d')+30,date('Y')))."<br/>";

?>


and in MySQL



SELECT "2010-09-07 17:12:20" + INTERVAL 30 DAY;
A
ashumak author 9/8/2010

Thanks,
But I was looking for something..if possible, to put into the default for a field. Short and sweet...
Alan

P
Pkas 9/8/2010



Thanks,
But I was looking for something..if possible, to put into the default for a field. Short and sweet...
Alan


Do it in your program.

Adding 30 days for an expiration is a business rule and shouldn't be part of your database design.

Sergey Kornilov admin 9/8/2010

If you are talking about default values in PHPRunner try the following:

date('Y-m-d H:i:s', mktime(date('H'),date('i'),date('s'), date('m'),date('d')+30,date('Y')))
A
ashumak author 9/15/2010



If you are talking about default values in PHPRunner try the following:

date('Y-m-d H:i:s', mktime(date('H'),date('i'),date('s'), date('m'),date('d')+30,date('Y')))



worked like a charm...
Now how about an SQL Query that would allow me to how only those records with a date that was either null or after the date above?
.....

FROM cc_lookup

WHERE (archive_date is Null etc...)

ORDER BY date_opened DESC