# Sort a HubDB query by date

**Technical Difficulty:** Advanced

**Written by** [Stephanie O'Gay Garcia](/content/hubspot-website-development/author/stephanie-ogay-garcia/index.html)

**First Published:** May 19, 2022  
**Last Updated:** May 19, 2022

⚠️ Note that this post hasn't been updated for at least a year and the information may be outdated, proceed with caution! _(Last updated: May 19, 2022)_

Let's assume you have a HubDB table (ID 12345) with two columns:

- A date column (Date type) with the column name "date"
- A title column (Text type) with the column name "title"

In your code, you can use the `orderBy` parameter to sort your table by a specific column (in this case, "date"), adding a minus symbol in front of it if you want to reverse the order. So your query parameters will either be `"&orderBy=date"` or `"&orderBy=-date"`

Using the [hubdb_table_rows](https://developers.hubspot.com/docs/cms/hubl/functions#hubdb-table-rows) function, this looks something like this:

```hubl
{% set queryparam = "&orderBy=date" %}
{% set press_items = hubdb_table_rows(12345, queryparam) %}
```

Note: if you've somehow landed on this post looking for a way to sort the actual HubDB table, unfortunately, that's not possible as of the time of writing this post unless you do some hacky export/order on a spreadsheet/re-import. But be sure to upvote the idea [here](https://community.hubspot.com/t5/HubSpot-Ideas/HubDB-rearrange-order/idi-p/5167)! In a recent update, HubSpot have said they're working on it so fingers crossed!
