Socrata was acquired by Tyler Technologies in 2018 and is now the Data and Insights division of Tyler. The platform is still powered by the same software formerly known as Socrata but you will see references to Data & Insights going forward.

date_trunc_y(...)

date_trunc_y(...)

Truncates a calendar date at the year threshold

Works with the following datatypes:

This function works with 2.0 and 2.1 endpoint(s). What does this mean? »

The date_trunc_y(...) function is used in the $select, $where, or $group parameters to truncate Floating Timestamps at the year level. For example, date_trunc_y('2012-09-22T18:05:00.000') would result in new timestamp of '2012-01-01T00:00:00.000'. This is handy for aggregation & display usages. For example, to aggregate the Chicago Crimes dataset by type and year:

https://data.cityofchicago.org/resource/6zsd-86xi.json?$select=date_trunc_y(date) as year, primary_type, count(*)&$group=year, primary_type