Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Compute Length of service every year

Author  Topic 

kimoy_bca
Starting Member

2 Posts

Posted - 2012-08-14 : 23:05:23
Hi I need help.

I want to compute the length of service rendered every year in terms of months based from the entered date and the LAST DAY of that particular year which you entered. For example, if the date entered is '01/02/2010', it will generate the difference which is 11 (because there are 11 months from January 2, 2010 to Dec. 31, 2010.

Sample outputs would be:

Date_entered Last_date_of_the_year Length(Month)
01/02/2010 12/31/2010 11
05/01/2011 12/31/2011 7

Hope you can help. Thank you.

Mr.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-08-14 : 23:14:39
datediff(month, Date_entered, Last_date_of_the_year) + 1


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -