Find out the last time user added the message. something like:Select @lastmsgdate = max(msgdate) from tbl where userid = 'someuser'
Now find out the difference between lastmsgdate and current datetime using DATEDIFF() to check whether two hours elapsed after last message added or not.select @hrselapsed = datediff(hour, @lastmsgdate, getdate())If @hrselapsed > 2-- okelse-- problem
Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"