You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

45 lines
860 B

return: date
lang: plpgsql
parameters:
p0:
type: anyelement
p1:
type: anyelement
p2:
type: anyelement
p3:
type: anyelement
strict: STRICT
src: |
DECLARE
i_century text;
i_year text;
i_month text;
i_day text;
return_date date;
BEGIN
i_century = $1;
IF (length(i_century ) <= 1) THEN
i_century = '0' || i_century;
END IF;
if i_century = '00' THEN
i_century = '00';
END IF;
i_year = $2;
IF (length(i_year ) <= 1) THEN
i_year = '0' || i_year;
END IF;
i_month = $3;
IF (length(i_month ) <= 1) THEN
i_month = '0' || i_month;
END IF;
i_day = $4;
IF (length(i_day ) <= 1) THEN
i_day = '0' || i_day;
END IF;
if i_day = '00' THEN
i_day = '01';
END IF;
return_date = to_date(i_century || i_year || i_month || i_day, 'YYYYMMDD');
return return_date;
END;