Hi,
I have a strange problem with the sc_date_dif macro.
I try to find out by date if a licence is valid or not. So I have a field in a grid “valid until” and a test field “days”.
The field “valid until” is a date field without regional settings and a detail mask “d-m-Y”.
In the grid’s events onRecord I put this code:
$today = date("Y-m-d");
$validuntil = {licence_valid_until};
{days} = sc_date_dif($today, 'dd.mm.aaaa', $validuntil, 'dd.mm.aaaa');
if({days} > 0)
{
{status} = 'ung?ltig';
//if amount is bigger then 0, means that current date is bigger then {field_due_date}
//send an email to the user, this bill is overdue.
}
elseif({days} == 0)
{
{status} = 'heute f?llig';
//if amount is 0, means that current date igual {field_due_date}
//send an email to the user, today is the payment day
}
elseif({days} < 0)
{
{status} = 'g?ltig';
//if amount is less then 0, means that {field_due_date} is bigger then the current date
//dont do nothing, the due date didnt pass yet
}
As result in my test field “days” I get strange results like negative numbers (-1431 for 23.09.2014 or for 24.04.2015, 27.04.2015 and 30.04.2015 I get for all ‘365’)
I experimented with all combinations of dd.mm.aaaa and Y-m-d … but can’t get the correct result.
Can anyone help?
Joe
