Page 1 of 1

Odd thing about sorting by timestamp

Posted: 2022-10-10 15:17
by smurphy
I am trying to sort my records by descending timestamp so the most recent records appear at the top of the table. There is a timestamp field of type VarChar that has a default value of <%%creationDateTime%%>, and I've set the table to sort by that field, descending.

The records are sorted correctly for those created 10/5/2022 through 10/9/2022, but when I inserted a record today, 10/10/2022, it displays at the bottom of the table, under the 10/9 2022 records.

I found in the forum how to use hooks to sort on a particular field, but how should I format my timestamp so that it will sort correctly? I've tried several formatting options, both through AppGini and using PHPMyAdmin, but everything I do seems to just break my timestamp :( Any help is appreciated.

Thanks,
Summer

Image

Re: Odd thing about sorting by timestamp

Posted: 2022-10-10 16:26
by jsetzer
Try changing the datatype from varchar to something numeric like int and ensure your database gets updated.

When sorting a numeric field, 9 < 10.
But when sorting a varchar field, "9" > "10".