How to find the number of days between two dates

后端 未结 9 661
独厮守ぢ
独厮守ぢ 2021-01-04 06:43

I have a basic query:

SELECT dtCreated
    , bActive
    , dtLastPaymentAttempt
    , dtLastUpdated
    , dtLastVisit
FROM Customers
WHERE (bActive = \'true\         


        
9条回答
  •  自闭症患者
    2021-01-04 07:27

    DECLARE @Firstdate DATE='2016-04-01',
     @LastDate DATE=GETDATE(),/*get today date*/
     @resultDay int=null
    
    SET @resultDay=(SELECT DATEDIFF(d, @Firstdate, @LastDate))
    PRINT @resultDay
    

提交回复
热议问题