--------TIME FUNCTION
CREATE FUNCTION Udf_DisplayTime (@DATE DATETIME)
RETURNS @TIMELIST TABLE ([TIME] DATETIME)
AS
BEGIN
DECLARE @I INT
DECLARE @C INT
SELECT @I = DATEPART(HH,@DATE)
SET @C = 0
WHILE (@I<24)
BEGIN
INSERT INTO @TIMELIST([TIME]) SELECT DATEADD(HH,@C,@DATE)
SET @I =@I+1
SET @C = @C+1
END
RETURN
END
SELECT * FROM Udf_TIME (GETDATE())
--- TIME PROCEDUERE
CREATE PROCEDURE Proc_Time (@DATE DATETIME )
AS
BEGIN
DECLARE @I INT
DECLARE @CNT INT
DECLARE @TAB TABLE ([TIME] DATETIME )
SELECT @I = DATEPART(HH,@DATE)
SET @CNT = 0
WHILE (@I<24)
BEGIN
INSERT INTO @TAB ([TIME]) SELECT DATEADD(HH,@CNT,@DATE)
SET @I =@I+1
SET @CNT = @CNT +1
END
SELECT * FROM @TAB
END
EXEC PROC_TIME '2011-06-30 19:03:03.437'
No comments:
Post a Comment