Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DateTime.Date Property

Gets the date component of this instance.

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

public DateTime Date { get; }

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.


DateTime date1 = new DateTime(2008, 6, 1, 7, 47, 0);
outputBlock.Text += date1.ToString() + "\n";

// Get date-only portion of date, without its time.
DateTime dateOnly = date1.Date;
// Display date using short date string.
outputBlock.Text += dateOnly.ToString("d") + "\n";
// Display date using 24-hour clock.
outputBlock.Text += dateOnly.ToString("g") + "\n";
outputBlock.Text += dateOnly.ToString("MM/dd/yyyy HH:mm") + "\n";
// 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


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft