postgresql - Need to filter my sql results for the last 4 days -
i need filter return last 4 days current date. struggle has been in using dateadd() , now() functions because keep keeping getting errors. advice?
as of sql statement:
select count(*) count, date(created_at) created_at account group date(created_at) order created_at asc
the output this:
"result": [ { "count": "1", "created_at": "2016-11-12t06:00:00.000z" }, { "count": "2", "created_at": "2016-11-13t06:00:00.000z" }, { "count": "1", "created_at": "2016-11-14t06:00:00.000z" }, { "count": "2", "created_at": "2016-11-15t06:00:00.000z" } ],
edit: using postgres , think changes kind of functions can use identify date.
you want simple where
clause. assuming have no future dates:
select count(*) count, date(created_at) created_at account created_at >= date_sub(curdate(), interval 4 day) group date(created_at) order created_at asc;
Comments
Post a Comment