The date argument is any expression that represents a date as a string.
The Day function locates and returns the numeric day portion of a date string as an integer. It performs no range validation on this number. The Day function accepts blanks, slashes (/), hyphens (-), or commas (,) (in any combination) as date component separators. Leading zeros and plus or minus signs may be included or omitted in the input string; leading zeros and signs are omitted from the output integer. The Day function locates the day portion in either of two ways:
In American format, the month precedes the day. For example, “9/27/2005” or “September 27, '05.” In this format, the Day function identifies the day portion by position. It does not parse the month or year components of the date string. These can be any alphanumeric value, and can include or omit punctuation characters such as periods or apostrophes. The year component may be 4-digits, less than 4 digits, or omitted.
In European written format, the day precedes the name of the month. For example, “27 September 2005” or “27 Sept” In this case, the month name is validated; the first three letters must correspond to a valid month name. Validation is not case-sensitive.
If the Day function is unable to identify a day portion of a string, it returns 0.
The following example uses the Day function to return the current day of the month:
Dim MyDay MyDay = Day(Date) Print MyDay
The following examples use the Day function to obtain the day of the month from a specified date:
Dim MyDay MyDay = Day("09-19-2005") 'MyDay contains 19. Print MyDay
Dim MyDay MyDay = Day("09/19/05") 'MyDay contains 19. Print MyDay
Dim MyDay MyDay = Day("Sept 19, 2005") 'MyDay contains 19. Print MyDay
Dim MyDay MyDay = Day("19 October") 'MyDay contains 19. Print MyDay
Dim MyDay MyDay = Day("19 Feb") 'MyDay contains 19. Print MyDay