Mysql does not return timediff value

Asked

Viewed 36 times

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()));
  • 1

    It seemed to work here: https://www.db-fiddle.com/f/qhUvN7eQBK4cFYBdg8xCdS/0. It can do a [mcve] reproducing the problem?

  • 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?

  • 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);

  • 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 ?

  • 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.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.