我如何选择两年日期之间的月份 [英] how can i select months between two year dates

查看:60
本文介绍了我如何选择两年日期之间的月份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的C#应用​​程序中使用Moth_Diff,但它不存在于表中,仅存在于此过程中.它在应用程序接口中返回空值



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



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

推荐答案

您不需要@tela就像这样使用GETDATE():

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

...DATEDIFF(MONTH, Reg_year ,GETDATE())...


这篇关于我如何选择两年日期之间的月份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆