开发者

Subtracting Datetime in SQL query

I have a Sql view Im trying to write and I'd like to be able to take my DateTime Field (called OrderDate) and then subtract it from the current Time (GetDate()) to show me how long its been in days sinc开发者_Python百科e the OrderDate. Can someone help out?

Thanks


I am assuming you are using SQL Server, since you mention the T-SQL GETDATE() function.

For calculations on differences between two date, use the DATEDIFF function:

SELECT DATEDIFF(day, OrderDate, GETDATE())
FROM myTable
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜