Last active
February 9, 2023 04:19
-
-
Save yogonza524/9c3787fef55748793208 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION date_arg_format(fecha date) | |
RETURNS CHARACTER VARYING AS $$ | |
DECLARE | |
mes double precision; | |
mes_salida character varying(20); | |
BEGIN | |
IF (fecha IS NOT NULL) THEN | |
mes = date_part('month',fecha); | |
CASE mes | |
WHEN 1 THEN mes_salida = 'Enero'; | |
WHEN 2 THEN mes_salida = 'Febrero'; | |
WHEN 3 THEN mes_salida = 'Marzo'; | |
WHEN 4 THEN mes_salida = 'Abril'; | |
WHEN 5 THEN mes_salida = 'Mayo'; | |
WHEN 6 THEN mes_salida = 'Junio'; | |
WHEN 7 THEN mes_salida = 'Julio'; | |
WHEN 8 THEN mes_salida = 'Agosto'; | |
WHEN 9 THEN mes_salida = 'Septiembre'; | |
WHEN 10 THEN mes_salida = 'Octubre'; | |
WHEN 11 THEN mes_salida = 'Noviembre'; | |
WHEN 12 THEN mes_salida = 'Diciembre'; | |
END CASE; | |
ELSE | |
RAISE EXCEPTION 'La fecha es nula, no se puede castear'; | |
END IF; | |
RETURN date_part('day',fecha) || ' de ' || mes_salida || ' de ' || date_part('year',fecha); | |
END; | |
$$ | |
LANGUAGE PLPGSQL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ej: "1 de Diciembre de 2015".