本文介绍了今天在storeprocedure的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在storeprocedure编码中获取今天的日期。

使用命令文本时这将使用datetime.Today()完成。

但是今天如何在storeprocedure中获取日期?



i使用查询选择检查时间..

how to get today date in storeprocedure coding.
when using command text this will done using datetime.Today().
but how to get today date in storeprocedure?

i have select checktime using query ..

select  top 1 @CheckType=CheckType,@CheckTime=CheckTime,@Userid=Userid,@Logid=Logid from Checkinout order by logid desc





现在如果检查时间是今天的日期然后更新记录。我已经做了....



now if checktime is today date then update record .for this i have do ....

if(@CheckTime = getdate())
	begin
UPDATE       Biometrics
SET                [Name] = @Name,[Date]=InTime ,Group_Id = @Groupid, OutTime = @CheckTime, Duration=DATEDIFF(mi, InTime , @CheckTime)  where  id=@id
	end



但我的记录没有更新。问题是什么?


but my record not updated.what is problem?

推荐答案

SELECT GETDATE() AS TodaysDate


if( Convert(varchar,@CheckTime,101) = Convert(varchar,getdate(),101) )
begin
UPDATE  Biometrics
SET  [Name] = @Name,[Date]=InTime ,Group_Id = @Groupid, OutTime = @CheckTime, Duration=DATEDIFF(mi, InTime , @CheckTime)  where  id=@id
    end







plz投票并接受ans,如果有帮助你的话:)

如果有效为ui wll解释你的代码wsnt workin



快乐编码伙伴:)




plz vote and accept ans if it helps u :)
if it works for u i wll explain u y ur code wsnt workin

happy coding buddy :)


这篇关于今天在storeprocedure的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 01:22