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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 automatic column calculation

Author  Topic 

Arun.G
Yak Posting Veteran

81 Posts

Posted - 2010-06-15 : 08:12:27
My Table is like below:

empid org status effectivefrom months remarks
1 aaa trainee 2002-05-08 6 ok
2 aaa probation 2002-07-08 2 gud


in empid=1 the moths value 6 is the differnce between the effectivefrom column date(2002-05-08)and **effectivefrom(2001-11-08)

in empid=2 the months value 2 is the difference between the effectivefrom column date(2002-05-08) and effectivefrom(2002-07-08)

the months column should be caluclated automatically

** effectivefrom(2001-11-08) is coming from another table which is the joining date of the employee.

so from joiningdate to trainee he worked for 6 months and trainee to conformation he worked for 2 months

how to calculated this automatically in stored procedure?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-06-15 : 08:39:43
basically you can use dateadd()
example
dateadd(month, 6, '2002-05-08')


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

Go to Top of Page
   

- Advertisement -