Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Will the above codes give the number of days between 2 dates?

I have a stored procedure which is not running because it "Times out" and this code

was the latest to be introduced

SQL
SET @FDATE   =  DATEADD(DAY,@FDAY-1,DATEADD(MONTH,@CMTH-1,DATEADD(YEAR,@CYR-1900,0)))


                            IF @CCMTH = 12
                              BEGIN
                              SET @CCMTH = 1
                              SET @CCYR  = @CCYR+1
                              END
                            ELSE
                              IF  @CCMTH <> 12
                              BEGIN
                              SET @CCMTH =@CCMTH+1
                              SET @CCYR  =@CCYR
                              END
                SET @ZDATE   =  DATEADD(DAY,@FDAY-1,DATEADD(MONTH,@CCMTH-1,DATEADD(YEAR,@CCYR-1900,0)))


                SET @ZDAY    =  DATEDIFF(DAY,@FDATE,@ZDATE)
Posted

1 solution

DATEDIFF(DAY, startdate, enddate) will[^] indeed return the difference of those dates in days.
I don't think that this is the cause of timing out. What should the rest of the posted code do? Try to debug: https://msdn.microsoft.com/en-us/library/hh272701%28v=vs.103%29.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900