Name
Day Function
Class
Microsoft.VisualBasic.DateAndTime
Syntax
Day(datevalue
)
-
datevalue
Use: Required
Data Type: Date or literal date
Return Value
An Integer from 1 to 31, representing the day of the month
Description
Returns an Integer ranging from 1 to 31, representing the day of the
month of datevalue
Rules at a Glance
The range of datevalue
is 1/1/1 to
12/31/9999.
Programming Tips and Gotchas
When working with dates, always check that a date is valid using the
IsDate
function prior to passing it as a function parameter.With
Option
Strict
On
, you must first convertdatevalue
to a Date data type before passing it to the Day function. You can use the CDate function for thi s purpose.If the day portion of
datevalue
is outside of its valid range, the function regenerates runtime error 13, “Type mismatch.” This is also true if the day and month portion ofdatevalue
is 2/29 for a non-leap year.To return the day of the week, use the
WeekDay
function.
See Also
Get VB .NET Language in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.