DATE_FORMAT in Postgresql? [duplicate]
You could use TO_CHAR
to format the date or timestamp.
SELECT count(*) AS aggregate
FROM contracts
WHERE TO_CHAR(created_at, 'yyyy-mm') = '2022-01'
Or use a sargable alternative
SELECT count(*) AS aggregate
FROM contracts
WHERE created_at >= '2022-01-01'
AND created_at < '2022-02-01'