Solved

How to use the Time type and retrieve

Posted on 2012-03-24
3
271 Views
Last Modified: 2012-03-25
I am confused as to how to use the Time type in inserting data in my table.  Currently I have Time as the type and 17:00:00 (hours:min:sec) as the way I am entering but am unable to retrieve it as 5:00 PM.

 I have tried DATE_FORMAT(%H, i%) but it does not seem to work.

 The actual syntax was:
Select example.Name, example.DAY, DATE_FORMAT(example.TIME(%H,%I))
FROM example

and

So I think I am doing everything wrong.  Any help would be appreciated.
0
Comment
Question by:dloj
  • 2
3 Comments
 
LVL 24

Expert Comment

by:johanntagle
ID: 37761928
syntax is date_format(column_name, 'formatting options')
0
 
LVL 24

Accepted Solution

by:
johanntagle earned 500 total points
ID: 37761937
to get that format you should use '%h:%i %p' as your format options.  BTW if the column is just of TIME type better to use TIME_FORMAT see http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_time-format
0
 

Author Closing Comment

by:dloj
ID: 37762870
Yes, I had used TIME_FORMAT but thanks for making that clear to me.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question