[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 290
  • Last Modified:

How to use the Time type and retrieve

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
dloj
Asked:
dloj
  • 2
1 Solution
 
johanntagleCommented:
syntax is date_format(column_name, 'formatting options')
0
 
johanntagleCommented:
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
 
dlojAuthor Commented:
Yes, I had used TIME_FORMAT but thanks for making that clear to me.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now