Kbase 13842: Example: creating output file name using DATE function
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/05/1998 |
|
Example: creating output file name using DATE function
/* Filename in this example will follow the format:
cmr031795.sac
Where "03" is the month, "17" the day, and "95" the year.
Programmers of course can change this to meet their needs. */
def var fname as char format "x(16)".
def var dd as date.
def var m as char.
def var y as char.
def var d as char.
dd = TODAY. /* Use today's date as an
example, but any date
will do. */
m = STRING(MONTH(dd)). /* Get numeric for month */
IF LENGTH(m) = 1 THEN m = "0" + m. /* If month is a single
digit, append a "0"
to the front. E.g.,
if m = "3" then make
m = "03". */
d = STRING(DAY(dd)). /* Get numeric for day. */
IF LENGTH(d) = 1 THEN d = "0" + d. /* If day is a single
digit, append a "0"
to the front. */
y = STRING(YEAR(dd)). /* Year will always be four chars. */
y = SUBSTRING(y,3,2). /* Use only the last two digits of year.
E.g., if "1995" then use "95". */
fname = "cmr" + m + d + y + ".sac". /* Build file name
for report output. */
OUTPUT TO VALUE(fname). /* Direct output to file. */
FOR EACH customer:
DISPLAY customer.name.
END.
Progress Software Technical Support Note # 13842