Is there a way to automatically update the offset in the query when tijdtot is negative
P粉023326773
P粉023326773 2023-09-12 22:58:55
0
1
609

I have a question. I have a query that calculates how many days until the next Grand Prix event in a list. Then I use the offset, if the event goes to 0 days or negative, I actually want to automatically go to the next positive number. I calculate Timeto between datetime and curdate in a table.

SELECT
    gp_naam, VT1, VT2, VT3, kwalificatie, race, image, CURDATE(),
    DATEDIFF(VT1, CURDATE()) AS Tijdtot
FROM grand prix
ORDER BY Tijdtot ASC
LIMIT 1 OFFSET 1

I've tried everything and I think I need to do something with the WHERE Timeto >0 but it won't accept it and causes an error. Does anyone know how I can solve this problem? Thanks in advance for your help and comments

P粉023326773
P粉023326773

reply all(1)
P粉026665919

You can use a similar method to get the countdown:

SELECT
    gp_naam, VT1, VT2, VT3, kwalificatie, race, image,
    TIMESTAMPDIFF(DAY, NOW(), VT1) AS days,
    TIMESTAMPDIFF(HOUR, NOW(), VT1) % 24 AS hours,
    TIMESTAMPDIFF(MINUTE, NOW(), VT1) % 60 AS mins
FROM grand_prix
WHERE VT1 > NOW()
ORDER BY VT1 ASC
LIMIT 1;
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template