dhananjay.nagarkar (2/14/2014)
Dear friends,I needed a urgent help on a critical task, for a field named "[ORC Position Duration (months)]"- I need to Calculate number of days from the "Target Start Date" through the "Temporary Assignment End Date" (including both the start date and end date) , -- Note I need to make sure that I include BOTH the Start Date and End Date in calculating the number of days between these two dates hence I wrote a code as below but I'm not sure will it work or not , if not please advice me the right code to accomplish this.
------ My code is as below---------------
Select
CONVERT(FLOAT,DATEDIFF ( DAY, [Pending].[Req# Target Start Date] ,[Pending].[Temporary Assignment End Date] ) + 1) AS [ORC Position Duration (months)]
From dbo.pending
--------------------------
Thanks
DJ
Can you post the ddl and a few rows of sample data including the expected output? It is difficult to determine what you are trying to do here.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/