Jump to content

Sorting "time" results


PHPilliterate

Recommended Posts

I have an issue with a schedule. In one line of my table for "time", but being new to phpmysql, I made the mistake of having my data as "9:00AM" or "6:30PM".The problem is that my sort for "time" shows as 6:00PM is earlier than 9:00AM.

 

Here is script for the sorting:

 

SELECT *
FROM ALFL
WHERE (visitorTeam LIKE '%ParamvisitorTeam%' OR '-1' = 'ParamvisitorTeam') OR (homeTeam LIKE '%ParamhomeTeam%' OR '-1' = 'ParamhomeTeam')
ORDER BY MONTH ASC, day, time, diamond

 

Is there a "php for idiots" type of solution for this?

Link to comment
Share on other sites

Your best solution would be to change to a standard sql DATETIME (I see that you have some month/day columns) data type. This will result in the fastest operating application, especially if you expect the amount of data in the database to grow over time.

 

Storing the date and time in a single DATETIME data field will simplify all your code and queries, result in the fastest performance, and result in the minimum storage requirements.

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.