Subject | SP to calculate time between two given timestamp |
---|---|
Author | Muthu Annamalai |
Post date | 2004-05-22T00:47:09Z |
Hi,
Somebody have to help me with my Stored Procedure.
The purpose of the stored procedure is to get the time worked.
That is when login time and logout time is given, I need to get the
time logged in to the system.
For example if two dates May 21 and May 28 given for a particular
user then I have to calculate the hours worked from the systemlog
table which has ID, USERID, LOGIN, LOGOUT,REGISTERID
MY SP
CREATE PROCEDURE GETHOURSWORKED(
USERID INTEGER,
FROMTIME TIMESTAMP,
TOTIME TIMESTAMP)
RETURNS (HOURSWORKED NUMERIC(2,2))
AS
BEGIN
FOR SELECT SYSTEMLOG.LOGOUT - SYSTEMLOG.LOGIN FROM SYSTEMLOG
WHERE SYSTEMLOG.USERID =:USERID AND
SYSTEMLOG.LOGIN =:FROMTIME AND SYSTEMLOG.LOGOUT = :TOTIME INTO
HOURSWORKED
DO SUSPEND;
END
Thanks
Muthu Annamalai
Somebody have to help me with my Stored Procedure.
The purpose of the stored procedure is to get the time worked.
That is when login time and logout time is given, I need to get the
time logged in to the system.
For example if two dates May 21 and May 28 given for a particular
user then I have to calculate the hours worked from the systemlog
table which has ID, USERID, LOGIN, LOGOUT,REGISTERID
MY SP
CREATE PROCEDURE GETHOURSWORKED(
USERID INTEGER,
FROMTIME TIMESTAMP,
TOTIME TIMESTAMP)
RETURNS (HOURSWORKED NUMERIC(2,2))
AS
BEGIN
FOR SELECT SYSTEMLOG.LOGOUT - SYSTEMLOG.LOGIN FROM SYSTEMLOG
WHERE SYSTEMLOG.USERID =:USERID AND
SYSTEMLOG.LOGIN =:FROMTIME AND SYSTEMLOG.LOGOUT = :TOTIME INTO
HOURSWORKED
DO SUSPEND;
END
Thanks
Muthu Annamalai