Click here to Skip to main content
15,909,591 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i want to Use Moth_Diff in my c# application but it does not exist in a table it only exist in this procedure.It returns a null value in tha Application interface



SQL
USE [DUT_Governance_Department]
GO
/****** Object:  StoredProcedure [dbo].[StudentsRespective_Studlog]    Script Date: 09/26/2010 10:30:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Proc [dbo].[StudentsRespective_Studlog]
(@User_names char(8)

 )
as
Declare @tela int = CONVERT(int,GETDATE(),111)

select Students.User_names,F_name,Vote_status,Reg_status,Reg_year ,Regions.Region_name,Function_ID.Function_id,DATEDIFF(MONTH, Reg_year ,@tela)as Month_Diff
from Students,Regions,User_Account,Faculty,Campus,Function_ID   
where  Students.User_names =User_Account .User_names 
AND Faculty.faculty_id =Students.faculty_id
AND Campus.Campus_id=Faculty.Campus_id
AND Regions.Region_id=Campus.Region_id
AND Function_ID .Function_id =User_Account.Function_id 
AND Students.Vote_status in('N','Y')
AND Function_ID.Function_id =4
AND Students.User_names =@User_names
Posted

1 solution

You don't need the @tela just use GETDATE() like this :

SQL
...DATEDIFF(MONTH, Reg_year ,GETDATE())...
 
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