I have a field of date-time type. I added this field into a view and formatted the date-time field to show only year. When I switch 'aggregation' on in Views and try to group this field it didn't work as i expect and show all the dates again. I saw the Vies-query and there wasn't any preformatting. It was grouping by dis field only. I want the modify the query to get this fields formatted as i need(years only). Any advices would be appreciated. Thanks in advance!
I don't think (I haven't seen your view) you need to enable aggregation to group by year. This is a solution:
If you need to display the date field value add the field twice. You will use one for the display of the date and the other for the grouping by year. If you are not going to display the date, you still need the date field to be able to group by year.
On the date field you are going to use to group by year you need a custom format that will only show you the year and if you are collecting both start and end date set it to you only the start date or the end date, but not both.
To create a custom date format go to admin/config/regional/date-time in Drupal 7 or to admin/settings/date-time in Drupal 6. There you will create a date format that will only show the year and then create a date format type that will show that date format.
Back to the date field you want to use to group by year change its format to the newly create format that only show you the date and set you show only one date and click apply. Also if you don't want the year value to show on the view check the option to exclude it.
Depending on the view format you have chosen (Table, Unformatted list, HTML list, etc) you will click the setting of the format and you are going to set the date field with the newly date format as the grouping field. Click apply and you are done.
You might also want to visit the "sort" section of your view to set the sort order of the dates.