Odd thing about sorting by timestamp

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
smurphy
Posts: 3
Joined: 2022-10-05 09:12

Odd thing about sorting by timestamp

Post by smurphy » 2022-10-10 15:17

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

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1944
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Odd thing about sorting by timestamp

Post by jsetzer » 2022-10-10 16:26

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".
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 25.10 + all AppGini Helper tools

Post Reply