Select time from datetime in SQL Compact

若如初见. 提交于 2019-12-24 10:47:36

问题


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?


回答1:


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

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




回答2:


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



来源:https://stackoverflow.com/questions/15760696/select-time-from-datetime-in-sql-compact

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!