Testing Multiple Conditions with "if" clause in calc element

Status
Not open for further replies.

ranwilli

Member
Using a calculated field to test whether or not a dated contract is in effect.

using this php code:

Code:
$effdate = '{authorizations_129_repeat___effective_date}';
$exdate = '{authorizations_129_repeat___ex_date}';
$today = date("Y-m-d H:i:s");

if ($today < $exdate) && ($effdate =< $today){
return '1';
} else {
return '0';
}
oddly, I can display all three vars, and the if statement tests correctly if one or the other tests is used, but refuses to work if BOTH are tested...

Any ideas?
 
Thanks for the suggestion, tried it, and also tried
Code:
if ($effdate =< $today < $exdate) {

alas, no joy!
 
Thanks for that!

the box at present:
Code:
$effdate = '{authorizations___effective_date}';
$exdate = '{authorizations___ex_date}';
$today = date("Y-m-d H:i:s");

if ($effdate <= $today) && ($today < $exdate) {
return '1';
} else {
return '0';
}

it is not working as of yet.
 
You can add
var_dump($effdate,$exdate,$today);exit;
to see what you get.

Maybe you have to use xxx_date_raw.
 
Maybe, If the single test works, try using nested if/else statements...

If today < effdate return false
else
if today > exdate return false
else
return true

...or something like that. This way you are only using one test at a time.

NickB
J2.5.7. F3.0.6.3 & latest Github
 
Thanks for that, another splendid idea...

Unfortunately, no joy,

Since I must move on, I've now got calc fields testing both as in:

past_effective
and
prior_to_expiry

And will have to write some rather more complex "WHERE" clauses in the other tables, but such is life.

If anyone knows what's up with this, post it here and I'll try your idea(s) as well.
 
You can add
var_dump($effdate,$exdate,$today);exit;
to see what you get.

Maybe you have to use xxx_date_raw.
That's handy...

I had done the same before by just returning each var, but every nugget helps.
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top