Subtract two dates in SQL and get days of the result

后端 未结 6 1742
你的背包
你的背包 2021-01-01 09:11
Select I.Fee
From Item I
WHERE GETDATE() - I.DateCreated < 365 days

How can I subtract two days? Result should be days. Ex: 365 days. 500 days..

6条回答
  •  -上瘾入骨i
    2021-01-01 09:25

    use DATE_DIFF

    Select I.Fee
    From   Item I
    WHERE  DATEDIFF(day, GETDATE(), I.DateCreated)  < 365
    
    • DATE_DIFF

提交回复
热议问题