Solved

How to use the Time type and retrieve

Posted on 2012-03-24
3
275 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

752 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