Jump to content

order by question with time


mikefrederick

Recommended Posts

i have a field in a table that contains times of the day in the format 11:00 am, 10:20 pm, etc. If I order by that field, then the pm dates will still come up before the am ones. For example, since 10:20 is less than 11 it will come before 11, but I need it to come after since it is actually later in the day. Is there anyway to do this without breaking the am/pm part into another field?

Link to comment
https://forums.phpfreaks.com/topic/96609-order-by-question-with-time/
Share on other sites

That seems like something impossible to do in SQL, but I'm not sure.

 

It's a good idea to store data in ways that a computer can work with better. I think you should store it as 24-hour time, or even as a number representing the number of seconds past midnight. Then when displaying it on the screen, you can format better it for a human to read.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.