ѕтƒ
ѕтƒ

Reputation: 3647

Retrieve time from MySQL as HH:MM format

I used DATETIME datatype to store date and time in my Database. It saved date as

YY-MM-DD HH:MM:SS (2012-11-06 10:45:48)  

I can retrieve the time from database as HH:MM:SS format but I want to retrieve it in HH:MM format.

How can I do this?

Upvotes: 10

Views: 37598

Answers (3)

Rolice
Rolice

Reputation: 3103

SELECT DATE_FORMAT( NOW() ,  '%H:%i' ) AS time_column

Upvotes: 6

Taryn
Taryn

Reputation: 247680

You will want to use DATE_FORMAT():

select date_format(yourDateColumn, '%h:%i') yourTime
from yourtable

See SQL Fiddle with Demo

Upvotes: 7

xdazz
xdazz

Reputation: 160833

Check the DATE_FORMAT Function.

SELECT DATE_FORMAT(date_column, '%H:%i') FROM your_table

Upvotes: 18

Related Questions