Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DATEDIFF() Function

Status
Not open for further replies.

suhash

Programmer
Joined
Aug 15, 2005
Messages
10
Location
GB
Hi there.
I have the following simple procedure. I dont get a value for @Diff. Any Ideas?

CREATE PROCEDURE RecordOptimise AS
declare @RecordDate datetime
declare @TimeNow datetime
declare @Diff int
Set @TimeNow = GETDATE()
select @Diff = DATEDIFF(ss, @RecordDate, @TimeNow)
select @RecordDate = (Select TimeOut From PeerFileListCollection Where PeerID ='11')
print @RecordDate
print @TimeNow
Print @Diff
GO


Thanks in advance

Mal.
 
Swap the order of these two lines to be:
select @RecordDate = TimeOut From PeerFileListCollection Where PeerID ='11'
select @Diff = DATEDIFF(ss, @RecordDate, @TimeNow)

This assumes the select of TimeOut will return ONLY one value.
 
Hi

I swap the statements, Now it works... Actually it should be the way how stupid i can be sometimes...

thanks for pointing out..

Mal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top