YEAR

YEAR(date)

Returns the year from a date (Integer).


dateThe date you want the year from (Variant).

REMARKS
* If "date" is Null, then Null is returned.
* The "date" can actually be any date, string or numerical expression.
* You can use the DATE function to return the current system date.
* You can use the DAY function to return the day from a given date.
* You can use the MONTH function to return the month from a given date.
* You can use the NOW function to return the current system date and time.
* The equivalent .NET function is Microsoft.VisualBasic.DateAndTime.Year
* For the Microsoft documentation refer to learn.microsoft.com

Debug.Print VBA.Now()                   '= 01/09/2023 23:56:17  
Debug.Print Year(VBA.Now()) '= 2021
Debug.Print Year("01/02/2020") '= 2020
Debug.Print Year("1 Feb 2020") '= 2020
Debug.Print Year("February 12, 2020") '= 2020
Debug.Print Year(256) '= 1900
Debug.Print Year(356) '= 1900
Debug.Print Year(2000) '= 1905

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top