Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get time (hh:mm:ss) from sql query?

I have Database with date field.

I see the time like: 1900-01-01 13:38:00.000

How i can format it like: 13:38 ?

like image 921
Gold Avatar asked Mar 15 '10 18:03

Gold


People also ask

How do I get HH MM from datetime in SQL?

By using format code as 106 we can get datetime in “DD MMM YYYY” format. By using format code as 107 we can get datetime in “MMM DD, YYYY” format. By using format code as 108 we can get datetime in “HH:mm: ss” format.

How do I get system time in SQL query?

The GETDATE() function returns the current database system date and time, in a 'YYYY-MM-DD hh:mm:ss. mmm' format.

How do I get hours and minutes in SQL?

We can use DATEPART() function to get the HOUR part of the DateTime in Sql Server, here we need to specify datepart parameter of the DATEPART function as hour or hh.


1 Answers

SELECT convert(varchar, getdate(), 108) outputs as hh:mm:ss.

like image 121
Yes - that Jake. Avatar answered Sep 16 '22 15:09

Yes - that Jake.