Date sorting in a table

Our system has its dates set to d/m/Y in General and are displaying no problem in the table:

<RowLoop type=voca>
      <Col>
      <Date><Field publish_date /></Date>
    </Col>
  </RowLoop>

When I sort on the the dates they do not sort correctly:

image

Is there something I should be doing that I have missed?

I gave this a quick test and it worked for me

<Head>
  <Col name=this_needs_a_name sort_type=date>Date</Col>
</Head>
<RowLoop type=voca>
  <Col>
    <Date><Field publish_date /></Date>
  </Col>
</RowLoop>

Let me know how it goes!

PS. Digging through the codebase the possible values for sort_type appear to be date, number, lowercase, and string. I’m pretty sure lowercase is just like string but ignores case entirely, and the rest are self-explanatory :slight_smile:

1 Like

It’s possible that the sort function is having difficulty with this particular date format. In that case, there’s a way to pass a timestamp for each column’s value for sorting purpose.

The Col tag accepts an optional attribute value, which is used for sorting, separate from the displayed value (the formatted date).

<RowLoop type=voca>
  <Col value="{Field publish_date date_format=timestamp}">
    <Date><Field publish_date /></Date>
  </Col>
</RowLoop>
1 Like