Solved

How to use the Time type and retrieve

Posted on 2012-03-24
3
268 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

More Fun with XML and MySQL – Parsing Delimited String with a Single SQL Statement Are you ready for another of my SQL tidbits?  Hopefully so, as in this adventure, I will be covering a topic that comes up a lot which is parsing a comma (or other…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

773 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