1
I am trying to create a direct query in mysql where I must return some value if the time interval of the current date and my datareg field is 02 minutes.
SELECT * FROM tabelax WHERE grade = 19 AND NOW() <= DATE_SUB(datareg, INTERVAL 02 MINUTE)
I tried to use now() with date_sub my datareg field, but I think I’m floating.
I also tried with DATEDIFF , but is not returning
SELECT * FROM tabelax WHERE grade = 19 AND DATEDIFF(NOW(), datareg) < 2
Any suggestions ?
By the brother thanks for your attention, A boy almost worked here but on the contrary, he’s returning me when minutes are longer than 02 minutes. Explain better, assuming: datareg: 2019-10-10 09:40:00 current date: 2019-10-10 09:42:00 If the result of datareg-datatual > 0 and <=2 then it would return me result, otherwise not. Via php is good to do this, now straight into mysql I’m catching rsrs I’ve read and reread some of the documentation from the conditional part, but it’s still unclear.
– Aquiles Maior
And turning the sign? <
– Eddy Albines
opa said wrong, datareg would be 2019-10-10 09:40:00 datatual would be 2019-10-10 09:38:00 , that is, subtracting 2 minutes left, I tried this but when the date is for example 09:41 is not to show result, only show as long as it is between 09:38 and 09:40
... AND (final_status2 >= datatual - INTERVAL 2 MINUTE AND final_status2 <= datatual)
, i.e., I am not able to condition this part– Aquiles Maior
Get it, try the second query
– Eddy Albines
Ufa worked, I added one more condition like you spoke, and reversed the current date of place. Valeuuuuuu too much there brother, broke a tree and helped me think rsrs.
... WHERE now() >= datahreg - INTERVAL 2 MINUTE AND now() <= datahreg
All together and stay with God ;)– Aquiles Maior
Nice to help you
– Eddy Albines