Hi all, just wondering what the best way is to structure time in sql database. For example, at present i use this format ; 19/08/2011 (which is day/month/year). when i call this in a sql statement, it shows all results, but not in a chronological order. Can any body solve this?

Cheers lovely people

You need to sort the result set using Order by on the date column in your SQL.

ex

select * From employee order by date_of_join

I have a sort on my statement already though bud, but it sorts on the first numbers first. I need it to sort in a chronological order. at present it sorts days regardless of the month eg:

21/08/2011
21/07/2011
20/08/2011
19/08/2011
18/08/2011
18/07/2011
17/07/2011

that means you have not stored your date using "date" datatype, you might be using varchar datatype.

So in short change datatype to "date" of that column

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.