Re: RES: [firebase-br] Update somente do Mês,
Luciano
luciano em praticsistemas.com.br
Qui Mar 31 07:51:34 -03 2005
Veja se isto te audará:
======================================
CREATE PROCEDURE INC_DEC_MES(
WDAT DATE,
WQTD SMALLINT)
RETURNS (
R_INC_DEC_MES DATE)
AS
DECLARE VARIABLE WDIA SMALLINT;
DECLARE VARIABLE WMES SMALLINT;
DECLARE VARIABLE WANO SMALLINT;
DECLARE VARIABLE WINT SMALLINT;
DECLARE VARIABLE WTRM CHAR(2);
DECLARE VARIABLE WTRD CHAR(2);
begin
wdia = extract(day from :wdat);
wmes = extract(month from :wdat);
wano = extract(year from :wdat);
wmes = :wmes + :wqtd;
if (:wqtd > 0) then
begin
while (:wmes > 12) do begin
wano = :wano + 1;
wmes = :wmes - 12;
end
end
else begin
while (:wmes < 1) do begin
wano = :wano - 1;
wmes = :wmes + 12;
end
end
if ((:wmes = 2) and (:wdia > 28)) then
begin
select r_mod from mod(:wano, 4) into :wint;
if ((:wint = 0) and (:wdia > 29)) then
wdia = 29;
else if ((:wint > 0) and (:wdia > 28)) then
wdia = 28;
end
else if (:wdia > 30) then begin
if ((:wmes = 4) or (:wmes = 6) or (:wmes = 9) or (:wmes = 11)) then
wdia = 30;
end
select r_IntZero from IntZero(:wdia, 2) into :wtrd;
select r_IntZero from IntZero(:wmes, 2) into :wtrm;
r_Inc_Dec_Mes = cast(cast(:wano as varchar(4)) || '-' ||
:wtrm || '-' || :wtrd as date);
suspend;
end
============ complementado com ===============
CREATE PROCEDURE MOD(
WRAD INTEGER,
WDIV INTEGER)
RETURNS (
R_MOD INTEGER)
AS
DECLARE VARIABLE T INTEGER;
begin
R_MOD = :WRAD - ((:WRAD / :WDIV) * :WDIV);
suspend;
end
============ complementado com ===============
CREATE PROCEDURE INTZERO(
WINT INTEGER,
WTAM INTEGER)
RETURNS (
R_INTZERO VARCHAR(36))
AS
begin
if (:wint is null) then
select r_replicate from replicate(:wtam, ' ') into r_IntZero;
else
select r_Sright from S_Right('000000000000000000' || cast(:wint as
varchar(18)), :wtam) into :r_intzero;
suspend;
end
Boa Sorte
Luciano C dos Santos
----- Original Message -----
From: "Gustavo André Tenan" <gustavo em tecbyte.com.br>
To: "FireBase" <lista em firebase.com.br>
Sent: Wednesday, March 30, 2005 12:08 PM
Subject: Re: RES: [firebase-br] Update somente do Mês,
> > Vamos supor que vc consiga incrementar somente o mes,
> >
> > 31/01/2005 + "1 mes" vai dar o que????? que resultado vc espera???
>
> Neste caso espero o último dia do próximo mês.
> >
> >
> > Rubem Rocha escreveu:
Mais detalhes sobre a lista de discussão lista