Filter By Date Parts or Date Field

To filter by a date part, use the WHERE clause with the EXTRACT() function, and pass it the desired date parts (year, month, or day). To filter by a date field, use the WHERE clause with a logical operator.

This example filters by year.

1SELECT CloseDate
2FROM "OpportunityFiscalEMTimezoned"
3WHERE EXTRACT(YEAR FROM CloseDate) = 2014;
CloseDate
2014-12-31 15:00:00
2014-12-30 16:00:00

This example returns CloseDate fields that occur on or before the given timestamp.

1SELECT CloseDate
2FROM "OpportunityFiscalEMTimezoned"
3WHERE CloseDate <= TIMESTAMP '2014-12-31 15:00:00';
CloseDate
2014-12-30 16:00:00