Click here to Skip to main content
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
0 OriginalGriff 330
1 Sergey Alexandrovich Kryukov 295
2 Gihan Liyanage 222
3 Abhinav S 172
4 ClimerChinna 167
0 Sergey Alexandrovich Kryukov 8,188
1 OriginalGriff 6,991
2 CPallini 2,598
3 Richard MacCutchan 1,925
4 Abhinav S 1,736


Advertise | Privacy | Mobile
Web01 | 2.8.140826.1 | Last Updated 30 Jan 2013
Copyright © CodeProject, 1999-2014
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