This topic is locked

Uing timestamp in a WHERE query

4/2/2022 11:48:56 PM
PHPRunner General questions
S
secs author

Hey all. I use Node-Red to populate my databse and have a field called Timestamp where I store the creation data as a timestamp 1648719718809 = Thursday, March 31, 2022 9:41:58.809 AM

How can I use the timestamp to show data older than 3 days? What I mean is I know I have to use WHERE currenttimestamp - timestamp > 259,200 being 86400 is one day and thus 3 times that is 3 days. But how do I get the current time stamp value into the where statement

P
ppradhan@live.com 4/3/2022

Hi, you can use this in After Table Initialized event:
$query->addWhere("DATE_SUB(CURDATE(), INTERVAL 3 DAY) <= Timestamp");

Sergey Kornilov admin 4/5/2022

Check this Stackoverflow post for inspiration.