dDateReference date.
AdvPL GuideYear(dDate) -> nYearExtracts the numeric year from a date.
Year takes a date and returns its four-digit year independently of SET DATE/SET CENTURY. An empty date returns zero. Converting an invalid string and assuming a valid year are different steps: validate type and origin. The community example uses Date(); this fixed-date adaptation makes the expectation independent of the clock. (Sources: refs. 1–2.)
Year(dDate) -> nYeardDateReference date.
Numeric; year, or zero for an empty date.
#Include "Protheus.ch"
User Function Ed734()
Local dReference := StoD("20261028")
// YYYYMMDD avoids depending on regional display formatting.
ConOut(Year(dReference))
Return NilExpected numeric result: 2026. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.
© 2026 Usina.BR. All rights reserved. TOTVS, Protheus, Microsiga and their respective logos are trademarks of their owners. AdvPL Guide is independent and uses limited, attributed excerpts justified by educational purposes. See the Terms of Use. Terms of Use
Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.