0
Good afternoon, I’m riding a Rigger in which I need to return the difference between two Datetimes. I’m trying to use the code below, but mysql does not return anything. If I run Select directly it returns without assigning a variable to the same mysql returns the time correctly... How can I solve this problem?
P.S.: I am using Phpmyadmin with mysql version 5.7.22
SET @dh = "2018-11-23 00:00:00";
SET @tempo2 = (SELECT TIMEDIFF(@dh,now()));
It seemed to work here: https://www.db-fiddle.com/f/qhUvN7eQBK4cFYBdg8xCdS/0. It can do a [mcve] reproducing the problem?
– Woss
Let me see if my cerebellum understood: You want to pick a difference between the time of the first variable and the value recorded in the mysql field. But it comes empty. Hey that?
– Risk
At the end of Rigger I try to pass the variable @tempo2 in an Insert but the same appears in the table as zero... INSERT INTO tb_paradas values (NULL,@time2,@dh);
– Marcelo
SET @dh = "2018-11-28 00:00:00";
SET @tempo2 = (SELECT TIMEDIFF(@dh,now()));
select @tempo2;
I did the test here and it worked, using mysql 5.7.19, when printing @time2 what happens ?– Bulfaitelo
It works directly in the command, but using a Trigger the result inserted in the table is zero, as said above... I ended up doing different, via SP where I got the result I wanted, but I still don’t have the answer why it doesn’t work on Rigger.
– Marcelo