/ Published in: SQL
This kind of functions will be use full if we are migrating a database from one provider to another like from MS SQL Server to Postgresql.
Expand |
Embed | Plain Text
CREATE OR REPLACE FUNCTION year (date1 Date) RETURNS integer AS $$ DECLARE YEAR_CONST Character Varying(15) := 'year'; yearPart Integer := 0; yearPartInDoublePrecision Double Precision := 0; BEGIN yearPartInDoublePrecision := date_part(YEAR_CONST, date1); yearPart := CAST(yearPartInDoublePrecision AS Integer); RETURN yearPart; END; $$ LANGUAGE plpgsql;
You need to login to post a comment.
