Description:
This function returns the year corresponding to a date. The year is returned as an integer in the range 1900-9999.
Syntax: YEAR (serial_number)
Remarks
Example
The YEAR function can be used in any database where you have stored values for the number of the serial date and you want to return the year element from that serial date, in this case it's possible to access this value with the help of this function. This function displays the year as a number derived from the computation of the parameter supplied to this function.
=YEAR (29058) |
-The parameter entered here for serial date is converted to a date and the year element in the date thus computed is returned by this function (The year returned for this example is = 1979) |
=YEAR ("range reference") |
-The parameter for "Serial Date" can be specified from a given range instead of being fed into the formula directly and the year element can be calculated based on the value thus passed to the formula. |
Let us take the example of the HR database in PowerOLAP where we need to calculate the Year value based on the information provided by the "Serial Date" parameter that is supplied to the function. In this case, we have written a formula in the appropriate cube in PowerOLAP, pulling in the value from the "Serial Date" field and then writing that value to this formula in order to calculate the result of the "YEAR" function. The formula then calculates the "Year" element as a number that corresponds to the actual year value for the date represented by the serial date.
The formula above writes values into the "Staff Date Lookup" cube to the "Staff Date Lookup" dimension into the member named "YearOfSerialDate" by calculating the appropriate value from the "Serial Date" member that is the parameter supplied and thus determining the value of the relative Year.