No announcement yet.

Sorting by date

  • Filter
  • Time
  • Show
Clear All
new posts

  • Sorting by date

    Hey, just got a question here. I'm building a content managing system for my site, and my site just happens to be on gaming. So when i go to do release dates, i have dates like "November 2002, Q3 2002, TBA" and others among my actual dates "November 5, 2001."

    So, i was wondering, is it possible to grab those dates from a DB and sort them corrently? And would the field in the DB be a date field, or varchar? Maybe have both and sort them that way?

    Thanks to any and all help you can give. And sorry if the explaination is bad.
    The Wiire

  • #2
    If you are going to store dates, store them as date or int types. You can sort on both, if you use int you will save timestamps, just as vb does it. If you want to see usage of date types look at the code in calendar.php. If you use timestamps you can't go before 1970 w/o headaches. Using date you can go back to around 1901. If you are going to be using present and future dates than either way works fine.


    • #3
      I understand how to sort as dates. But those are stored as yyyy-mm-dd. I need to sort by those dates, as well as things that don't fall into that format.

      Say, i have 5 different games i want to put on a release list, and i wanted to sort them by how soon they're being released. I end up with dates like:

      Game 1 - November 2001
      Game 2 - Canceled
      Game 3 - TBA
      Game 4 - Q4 2001
      Game 5 - November 5, 2001

      Now is it possible to sort those? A date field won't let me enter something like TBA. For Game 1, i guess i could go 2001-11-00, but that doesn't help for 2-4.

      So is that possible?
      The Wiire


      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.