Date Property

DateTime.Date Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets the date component of this instance.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

'Declaration
Public ReadOnly Property Date As DateTime

Property Value

Type: System.DateTime
A new object that has the same date as this instance, and its time value set to 12:00:00 midnight (00:00:00).

The following example uses the Date property to extract the date component of a DateTime value with its time component set to zero (or 0:00:00, or midnight). It also illustrates that, depending on the format string used when displaying the DateTime value, the time component can continue to appear in formatted output.


Dim date1 As Date = #6/1/2008 7:47:00 AM#
outputBlock.Text += date1.ToString() & vbCrLf

' Get date-only portion of date, without its time.
Dim dateOnly As Date = date1.Date
' Display date using short date string.
outputBlock.Text += dateOnly.ToString("d") & vbCrLf
' Display date using 24-hour clock.
outputBlock.Text += dateOnly.ToString("g") & vbCrLf
outputBlock.Text += dateOnly.ToString("MM/dd/yyyy HH:mm") & vbCrLf
' The example displays the following output:
'       6/1/2008 7:47:00 AM
'       6/1/2008
'       6/1/2008 12:00 AM
'       06/01/2008 00:00


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft