# Order by year instead of date

**URL:** <https://community.bloomreach.com/t/order-by-year-instead-of-date/1149>\
**Category:** Experience Manager (PaaS/OnPrem)\
**Created:** [June 4, 2019, 6:38pm UTC](https://community.bloomreach.com/t/order-by-year-instead-of-date/1149 "2019-06-04T18:38:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rakesh](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@rakesh](https://community.bloomreach.com/u/rakesh)\
**Post date:** [June 4, 2019, 6:38pm UTC](https://community.bloomreach.com/t/order-by-year-instead-of-date/1149/1 "2019-06-04T18:38:37Z")

</div>

Hi,

Is it possible to just order by year instead of the whole date.

Currently I am using

```auto
.orderBy("hippostdpubwf:publicationDate").descending();

```

Thanks,  
RK

---

<div class="post-metadata">

**Author:** ![machak](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/machak/32/1298_2.png) [@machak](https://community.bloomreach.com/u/machak)\
**Post date:** [June 5, 2019, 8:52am UTC](https://community.bloomreach.com/t/order-by-year-instead-of-date/1149/2 "2019-06-05T08:52:34Z")

</div>

see date resolution part:

> **[Optimize Delivery Tier API Queries with Date Range Constraints for Performance...](https://documentation.bloomreach.com/library/concepts/search/out-of-the-box-fast-date-range-query-support-from-hst.html)**
>
> Open Source Enterprise Content Management

---

<div class="post-metadata">

**Author:** ![rakesh](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@rakesh](https://community.bloomreach.com/u/rakesh)\
**Post date:** [June 5, 2019, 12:39pm UTC](https://community.bloomreach.com/t/order-by-year-instead-of-date/1149/3 "2019-06-05T12:39:45Z")

</div>

This seems to be the date range queries but how to sort the results just by year instead of the complete date?  
For example, if the publish date in the articles is 2019-05-06 then sort by just YYYY in that field.  
The reason is, I want my articles to be sorted based on year and title. I don’t want them to be sorted based on the complete date and title.

---

<div class="post-metadata">

**Author:** ![woonsanko](https://avatars.discourse-cdn.com/v4/letter/w/b5a626/32.png) [@woonsanko](https://community.bloomreach.com/u/woonsanko)\
**Post date:** [June 5, 2019, 1:29pm UTC](https://community.bloomreach.com/t/order-by-year-instead-of-date/1149/4 "2019-06-05T13:29:01Z")

</div>

Can you try this?

```auto
import org.hippoecm.repository.util.DateTools;
import org.hippoecm.repository.util.DateTools.Resolution;

//...
.orderByDescending(DateTools.getPropertyForResolution("hippostdpubwf:publicationDate", Resolution.YEAR));

```

---

<div class="post-metadata">

**Author:** ![rakesh](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@rakesh](https://community.bloomreach.com/u/rakesh)\
**Post date:** [June 5, 2019, 1:53pm UTC](https://community.bloomreach.com/t/order-by-year-instead-of-date/1149/5 "2019-06-05T13:53:46Z")

</div>

> [@woonsanko](#):
>
> Resolution.YEAR

That worked. Thanks a ton!
