I need to obtain only the time part of a datetime variable without the making it a text file so no varchar
is there a way to get only 9:11:02 from "1/2/2013 9:11:02" without varchar conversion?
I need to obtain only the time part of a datetime variable without the making it a text file so no varchar
is there a way to get only 9:11:02 from "1/2/2013 9:11:02" without varchar conversion?
try this format for mysql
SELECT DATE_FORMAT(tstamp,'%r') AS stamp from table name
E.G.
mysql> select * from test;
+---------------------+
| stamp |
+---------------------+
| 2013-10-10 09:10:11 |
+---------------------+
1 row in set (0.00 sec)
mysql> SELECT DATE_FORMAT(stamp,'%r') AS stamp from test;
+-------------+
| stamp |
+-------------+
| 09:10:11 AM |
+-------------+
1 row in set (0.00 sec)
Something like this
SELECT
CONVERT(VARCHAR(8),GETDATE(),108) AS Time,
OR
SELECT
CONVERT(TIME,GETDATE()) AS TIME
If you're using MSSQL, it's still conversion to varchar, but it's data presentation...
SELECT CONVERT(varchar, GETDATE(), 8)
select CAST('1/2/2013 9:11:02' as TIME)
This will give you the time with a trailing ".00..."