标签: sql sql-server sql-server-2008
我的表格有一个日期列'orderdate',类型为yyyy-mm-dd 我想得到getdate()
select getdate() - orderdate from table
这应该返回天数
答案 0 :(得分:2)
你需要使用它:
SELECT DATEDIFF(DAY,orderdate,GETDATE()) FROM table