LeoSam
LeoSam

Reputation: 4941

Postgres, count per month

Im using the followig query to get count per day ,

select count(*) as counter 
from art.pub 
WHERE createddate > CURRENT_DATE;

I want to adjust it and get it count per current month ,

any tips to adjust my query

Upvotes: 2

Views: 1874

Answers (2)

code save
code save

Reputation: 1106

Please try this , it will work on MS Sql server

select count(*) as counter 
from  ##TBL_TEMP
WHERE DATEPART(MONTH,createddate) > DATEPART(MONTH, GETDATE());

Upvotes: 0

valex
valex

Reputation: 24144

In PostgreSQL try to use date_trunc

WHERE createddate >= date_trunc('month', CURRENT_DATE)

Upvotes: 3

Related Questions