Consultor Eletrônico



Kbase 13506: HOW TO ADD to the YEAR of a DATE (example)
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/05/1998
HOW TO ADD to the YEAR of a DATE (example)

This kbase shows how to add one year to a date. It uses today's date
for the example, and prints both dates so that you can compare them.

/* Code Example: Adding one to the year of a date */

def var zz as character.
def var sdate as date format "99/99/9999" init today.

def var x as integer.
def var y as integer.
def var z as integer.
def var g as integer.

/* display the date so we know what we are working with */

display sdate label "start date" with frame foo1.
pause.

/* get the parts of the date */

x = year(sdate).
y = day(sdate).
z = month(sdate).

/* add one to the year */

x = x + 1.

/* reconstruct the date */

zz = string(z, "99") + string(y,"99") + string(x,"9999").
g = integer(substring(zz,5,4)).
sdate = date(z,y,g).

/* display the result to see if we got it right */

display sdate label "end date" with frame foo2.

Progress Software Technical Support Note # 13506