0

ok so i have a time that i need to order by but i dont know how to make it order, in order by am then pm.

Ex: i have to events that i put in the calendar one for 6:00 am and one for 9 pm. I put order my time DESC but all it does is put the 9:00 pm first

2
Contributors
9
Replies
10
Views
7 Years
Discussion Span
Last Post by itisnot_me
0

How is the date entered in the database? Kind of hard to figure out what the problem might be without more info (an example).

Edited by Encrypted: n/a

0

not the date just the time. 1:00 am, 2:00 am, 3:00 am etc. exactly like that as text

0

That's going to be a pain in the butt. lol You're going to have to search the string to see if 'a' exists in it to sort it by AM or PM and then sort it by the numbers. (At least that's the only way I can think of doing it.)


It's be much easier if you just entered the time using 00 through 23 for the hours and then sort it by minutes using 00 through 59. Or just convert it all into minutes and mod it by 60.

Edited by Encrypted: n/a

0

haha. i was just looking at that but i cant make sense of it right now

0

obviously it is that difficult. i understand the the time_format(time, '%I:%i%p'). but where do i get time from and how do i write the query in php.

this is new to me and i dont know how to do it. there is not much on google besides that post to help me along

0

can someone help me with this again. i never did figure it out. this is my query that i need to sort in time order with am/pm

SELECT * FROM eventcal WHERE company_id='$company_id' and email='$login_email' and eventDate='$today' ORDER BY eventDate DESC
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.