DAY

DAY(date)

Returns the day from a given date (Integer).


dateThe date you want the day from (Variant).

REMARKS
* The value returned is between 1 and 31.
* The "date" can be any date, text string, numerical expression or any combination.
* If "date" is Null, then Null is returned.
* If "date" is not a valid date, then a runtime error (13) is returned.
* If the date is a serial number representing a date after 31 Dec 1999, then a runtime error (13) is returned.
* This function uses the regional settings to decide if a date format is valid or not.
* You can use the DATE function to return the current system date.
* You can use the MINUTE function to return the minutes from a given time.
* 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.
* You can use the SECOND function to return the seconds from a time.
* You can use the TIME function to return the current system time.
* You can use the YEAR function to return the year from a given date.
* The equivalent .NET function is [[Microsoft.VisualBasic.DateAndTime.Day]]
* For the Microsoft documentation refer to learn.microsoft.com

Debug.Print Now()                     '= 18/02/2024 09:23:12  
Debug.Print Day(Now()) '= 18
Debug.Print Day("04/07/2024") '= 4
Debug.Print Day("4/7/2024") '= 4
Debug.Print Day("4/7/24") '= 4
Debug.Print Day("15 February 2024") '= 15

Debug.Print Day(0) '= 30, date = 00/01/1900
Debug.Print Day(1) '= 31
Debug.Print Day(2) '= 1

Debug.Print Day(35678) '= 5
Debug.Print Day(2958465) '= 31 Dec 9999
Debug.Print Day(2958465 + 1) '= Runtime Error 13
Debug.Print Day("04.07.2024") '= Type Mismatch

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