Evaluates a date expression and returns the year value of that date, including the century, as an INTEGER value.
YEAR ( date )
YEAR ( datetime-expression )An expression that evaluates to a DATETIME or DATETIME-TZ. The YEAR function returns the year of the date part of the DATETIME or DATETIME-TZ value.This procedure uses the YEAR function to determine if an Order date is in this century or the next, and then uses a different display format for each:
DEFINE VARIABLE outfmt AS CHARACTER NO-UNDO.DEFINE VARIABLE orddate AS CHARACTER NO-UNDOLABEL "Order Date" FORMAT "x(10)".FOR EACH Order NO-LOCK:ASSIGNoutfmt = IF YEAR(Order.OrderDate) >= 2000 THEN"99/99/9999" ELSE "99/99/99"orddate = STRING(Order.OrderDate, outfmt).DISPLAY Order.OrderNum orddate Order.Terms.END.ADD-INTERVAL function, DATE function, DATE-FORMAT attribute, DATETIME function, DATETIME-TZ function, DAY function, ETIME function, INTERVAL function, ISO-DATE function, MONTH function, MTIME function, NOW function, TIME function, TIME-SOURCE attribute, TIMEZONE function, TODAY function, YEAR-OFFSET attribute
© 2012 Progress Software Corporation and/or its subsidiaries or affiliates. |