Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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?
Posted
Updated 30-Jan-13 2:43am
v3

Replace ur condition wid below one


SQL
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 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 :)
 
Share this answer
 
In SQL you can do
SQL
SELECT GETDATE() AS TodaysDate
 
Share this answer
 
Comments
Member 9511889 30-Jan-13 8:40am    
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?
ZurdoDev 30-Jan-13 8:49am    
GetDate() includes the time so that is why @CheckTime is not working. What is in your @CheckTime?

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