Hi,

I've got some dates stored in a table just as a varchar, like:

02/02/2009
03/02/2009
05/03/2009

etc etc

The ordering seems to work but if have a date like 20/02/2007 it doesn't work and doesn't appear before the other 3 like it should.

So I'm guessing I've gone about this wrong, wondering what the best way of doing it is, should I convert my DD/MM/YYYY into something else?

Cheers

    The old date storage discussion!
    There are many ways to store dates. You can use one or more fields. You can store timestamps or formatted dates. You can also use the native date time format. Each method has some pros and cons. I personally often pick timestamps or IEEE (YYYYMMDD) formats depending on the manipulations I will have to perform on the data.

      why would you ever split a date in to multiple fields?

        Old mainframe systems very very often store dates in separate fields. I know, I had my hands in mainframe bowels for three years before the Y2K switch. I still wake up at night screaming from the nightmares I get when remembering what I saw back then. shivers

          welcome to the 20th century, how did you protect your websites from the dinosaurs ? 😃

            Store them in your database as date. This will store them like YYYY/MM/DD

            im gussing that this is your problem that it wont then display the date in the way you want it to. Just use a function within ur php code to change how it is formated and displayed back.

            Your order by will work and also you can display how ever you want.

            This is the best way that i have found to over come the problem

              Weedpacket;10902874 wrote:

              Welcome?

              thank you weedpacket, I'll work it out one day.

                Write a Reply...