I have an application in which I've used MySQL. I had a report that stretched records of the last 24 hours. I used the query:
WHERE (DATE_SUB(CURDATE(), INTERVAL 1 DAY) <= FROM_UNIXTIME(`workorder`.`CREATEDTIME` / 1000))
Now I have to use PostgreSQL and do not know how to make a report of the last 24 hours. Can any of you help?
select product_id, invoice_id, amount from mytable inner join (select max(date) as last_date, product_id, invoice_id from mytable group by product_id) sub on mytable. date = sub. last_date and mytable. product_id = sub.
WHERE workorder.createdtime > current_date - 1 -- Yesterday and today WHERE workorder.createdtime > current_timestamp - interval '1 day' -- last 24hr
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With