---
schema_version: "1"
id: 985c4c8ed1271e98c9c0259309ff910a1365a01e7f67c7f62c3a549f60ae28dd
title: Order By Date
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_saql/guides/concept/bi-saql-functions-timezone-order.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-functions-timezone-order.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 77c614789eda7a076fe07b40843ffe6180b2749120bc947c248044a10e8e31d5
products:
  - Analytics SAQL Developer Guide
  - analytics
---

# Order By Date

You can order the result of your SAQL queries by `DateTime` or `DateOnly`.

Use the date part to order by date before the projection. For example, you can order results by the year that they closed.

```nolang
q = order q by year('CloseDate');
```

To order by date after the projection, use the field you created by projecting a date part. For example, you can order results by the year that they closed.

```nolang
q = foreach q generate year('CloseDate') as "Year Closed";
q = order q by 'Year Closed';
```
