Hi, ne need to convert the following tsql function code into a pgsql function and I have absolutely no idea how:
BEGIN DECLARE @StartDate DATETIME DECLARE @ResultDate DATETIME
SET @StartDate = CONVERT(DATETIME, 0)
SET @ResultDate =
CASE @Type
WHEN 0 THEN DATEADD(mi, FLOOR(DATEDIFF(mi, @StartDate, @Date) / CAST(@Interval AS FLOAT)) * @Interval, @StartDate)
WHEN 1 THEN DATEADD(mi, CEILING(DATEDIFF(mi, @StartDate, @Date) / CAST(@Interval AS FLOAT)) * @Interval, @StartDate)
ELSE @Date
END
RETURN @ResultDate
thanks
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO
ALTER FUNCTION [dbo].[GetIntervalDate]
(
@Date DATETIME, @Type INT, @Interval INT
)
RETURNS DATETIMEAS
BEGIN
DECLARE @StartDate DATETIME
DECLARE @ResultDate DATETIME
SET @StartDate = CONVERT(DATETIME, 0) SET @ResultDate = CASE @Type WHEN 0 THEN DATEADD(mi, FLOOR(DATEDIFF(mi, @StartDate, @Date) / CAST(@Interval AS FLOAT)) * @Interval, @StartDate) WHEN 1 THEN DATEADD(mi, CEILING(DATEDIFF(mi, @StartDate, @Date) / CAST(@Interval AS FLOAT)) * @Interval, @StartDate) ELSE @Date END
RETURN @ResultDate END
Sorry, here is the fullquote