Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 289
  • 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

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