Mike Baxter
Mike Baxter

Reputation: 7268

Select time from datetime in SQL Compact

Much like this question: "How to get Time from DateTime format in SQL?", I am trying to select only the time from a datetime, but unlike the above question, I would like to know how to do it in SQL Server Compact. Does anyone know how to do this?

Upvotes: 1

Views: 2734

Answers (2)

Mike Baxter
Mike Baxter

Reputation: 7268

Solved it. Luigi's answer is not actually the correct one but I have upvoted it, as it helped me find the answer.

To get only the time from a datetime in SQL Server Compact, the proper query is:

select ltrim(str(DATEPART(hour, columnName))) + ':' + ltrim(str(DATEPART(minute, columnName))) + ':' + ltrim(str(DATEPART(second, columnName))) from table

Upvotes: 1

Luigi Saggese
Luigi Saggese

Reputation: 5379

SELECT DATEPART(hour, OrderDate), DATEPART(minute, OrderDate) FROM MyOrders

Ref. http://msdn.microsoft.com//library/ms173998%28v=sql.90%29.aspx

Upvotes: 1

Related Questions