With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.
DECLARE @MAXMONTHS INT SELECT @MAXMONTHS = MAX(DATEDIFF(MM,STARTDATE,ENDDATE)) + 1 FROM [Stage].[RESULTS] -- ADD 1 IN ORDER TO ACCOUNT FOR ROUNDING DOWN IN YEAR CALCULATION DECLARE @THISMONTH INT SET @THISMONTH = 1 WHILE (@THISMONTH <= @MAXMONTHS) BEGIN INSERT INTO [Stage].[TPHASES] SELECT R.SF_ID , R.AP_ID , @THISMONTH AS Phase , DATEADD(MM,@THISMONTH-1,R.STARTDATE) AS STARTDATE , DATEADD(D,-1,DATEADD(MM,@THISMONTH,R.STARTDATE)) AS ENDDATE FROM [Stage].[RESULTS] AS R INNER JOIN [Stage].[RESULTSWO] AS RWO ON RWO.SF_ID = R.SF_ID AND RWO.[ROW] = 1 WHERE R.[ROW] = 1 AND RWO.ENDDATE >= DATEADD(MM,@THISMONTH-1,R.STARTDATE) ORDER BY R.SF_ID SET @THISMONTH = @THISMONTH + 1 END ;
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
16 Experts available now in Live!