Click here to Skip to main content
11,565,352 members (40,082 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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 30-Jan-13 2:32am
Edited 30-Jan-13 2:43am
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

In SQL you can do
SELECT GETDATE() AS TodaysDate
  Permalink  
Comments
Member 9511889 at 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?
ryanb31 at 30-Jan-13 8:49am
   
GetDate() includes the time so that is why @CheckTime is not working. What is in your @CheckTime?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Replace ur condition wid below one


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 Smile | :)
if it works for u i wll explain u y ur code wsnt workin

happy coding buddy Smile | :)
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


Advertise | Privacy | Mobile
Web04 | 2.8.150624.2 | Last Updated 30 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100