I have a table named hr events
where, in one field, it outputs when a certain employee went on maternity leave;
On the return_date
field, it displays the date when the employee got back from the maternity leave.
If the employee has not come back yet, we set a default value, as seen on CREATE
statement below: CREATE (return_date DATE NOT NULL DEFAULT '0000-00-00',)
;
There is one last field on this report where it is supposed to show the employee's final return date to her activities: (c.return_date ,'%d/%m/%Y') AS c_return_date
. As an SQL beginner, i'm struggling with this: whenever we have a (default 0000-00-00)
value, c.return_date
brings some sort of aleatory date, like: e.g 12/01/1999 , tho' it's a NULL field.
I've been trying to treat this with ISNULL(c.return_date, '')
or ISNULL(c.return_date, 0)
but it just doesn't work. In the above scenario, this last field should be blank or anything but this '12/01/1999'.
As for PHP, and that's why I'm editing this topic, I think there could be a way out of this by addressing this issue inside the php script:
<?php
$retorno = (!empty($row['c_return_date'])) ? $row['c_return_date'] : $row['a_return_date'];
$data = explode('-', $retorno);
echo date("d/m/Y", mktime(0, 0, 0, $data[1], $data[2] + 1, $data[0]));
?>
I'm currently trying to figure out (actually, more figuring out how does this script works) how to validate this script to, in case of a return date like 0000-00-00
(which means the employee has not come back yet to her activities), not display these sort of output like 12/01/1999.