Skip to content

Year - Built-in Date & Time Function

Purpose

Year returns the year from a datetime expression.

Syntax

Year(Datetime)

Arguments

Argument Required Description
datetime Yes Any valid datetime expression from which the year will be returned

Returns

Integer

See also

Example

Dim dtSys

// the following returns the current year
Let dtSys = Now()

Return Year(dtSys)
// the following returns the number of years between two dates
Return (Year(Now()) – Year({Orderheader.Order_Date}))

Notes

  • When datetime cannot be converted to a datetime value, a runtime error is generated.
  • When date is passed as a string, your PC's regional settings are used for the conversion to datetime. If that fails, you get a runtime error.