Below is the CREATE TABLE statement used to create my table:
CREATE TABLE IF NOT EXISTS `data_received` (
`id` int(10) unsigned NOT NULL,
`edit_time` datetime NOT NULL}
Below is how data is saved in table if 'edit_time' value is not provided:
id edit_time
1 0000-00-00 00:00:00
Now, if I execute the following statement:
SELECT TIMESTAMPDIFF( HOUR , edit_time, NOW( ) ) AS diff_in_hours
FROM data_received;
I get result: NULL
Can someone please help me understand what is happening?
That is because 0000-00-00 00:00:00
is not a valid DATETIME
expression accepted by the function.
Please check documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With