Export (0) Print
Expand All

DateAndTime.Day Method

Returns an Integer value from 1 through 31 representing the day of the month.

Namespace:  Microsoft.VisualBasic
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public static int Day(
	DateTime DateValue


Type: System.DateTime

Required. Date value from which you want to extract the day.

Return Value

Type: System.Int32
Returns an Integer value from 1 through 31 representing the day of the month.

If you use the Day function, you might have to qualify it with the Microsoft.VisualBasic namespace, because the System.Windows.Forms namespace defines Day as an enumeration. The following example shows how qualifying Day resolves this ambiguity:

Dim thisDay As Integer = Microsoft.VisualBasic.DateAndTime.Day(Now)

You can also obtain the day of the month by calling DatePart and specifying DateInterval.Day for the Interval argument.

The following example uses the Day function to obtain the day of the month from a specified date. In the development environment, the date literal is displayed in standard short format (such as "02/12/1969") using the locale settings of your code.

Dim oldDate As Date 
Dim oldDay As Integer 
' Assign a date using standard short format.
oldDate = #2/12/1969#
oldDay = Microsoft.VisualBasic.DateAndTime.Day(oldDate)
' oldDay now contains 12.

Day is qualified to distinguish it from the System.Windows.Forms.Day enumeration.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft