Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

records from yesterday in postrgesql

Tags:

postgresql

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?

like image 863
Krokodyle Avatar asked Jul 28 '13 19:07

Krokodyle


People also ask

How do I get the latest date in PostgreSQL?

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.


1 Answers

WHERE workorder.createdtime > current_date - 1     -- Yesterday and today  WHERE workorder.createdtime > current_timestamp - interval '1 day' -- last 24hr 
like image 120
Curt Avatar answered Nov 06 '22 02:11

Curt