Page 1 of 1

Formatting Time

Posted: Wed Sep 20, 2006 9:22 am
by aquanutz
Is there any quick way to bring back a time as just '8 am' instead of '08:00 AM' in MySQL?

This is what I have thusfar that brings back the ladder of the above:

Code: Select all

TIME_FORMAT(monO, '%h:%i %p') as monO
Thanks for any input.

Posted: Wed Sep 20, 2006 9:40 am
by JayBird

Code: Select all

TIME_FORMAT(monO, '%h%p') as monO
??

Posted: Wed Sep 20, 2006 9:51 am
by aquanutz
Haha, yeah that works. I always fail to see the blatantly obvious.

I guess the real thing I need it to do is drop that preceeding '0' off the time so i get '8:00 am' instead. I've been looking and I don't think that I can bring it back like that, which means I'll just write a php function to take care of it.

Probably just better to write something myself because some times are 1-9 and some are 10-12 with :30 or :00 on the end.. and if it's just '08:00 AM' I just want '8 am' but if it has the :30 on the end I want that there too... from what I've read, sql can't do anything like what I need.

Anyhow, thanks for your reply.

Posted: Wed Sep 20, 2006 10:07 am
by aquanutz
yeah, i just wrote my own script to do it.

CLOSED