DateTime是一个DataType,用于存储
Date和
Time。但是它提供了属性以获取
Date零件。
您可以从
Date属性中获取日期部分。
http://msdn.microsoft.com/en-
us/library/system.datetime.date.aspx
DateTime date1 = new DateTime(2008, 6, 1, 7, 47, 0);Console.WriteLine(date1.ToString());// Get date-only portion of date, without its time.DateTime dateonly = date1.Date;// Display date using short date string.Console.WriteLine(dateOnly.ToString("d"));// Display date using 24-hour clock.Console.WriteLine(dateOnly.ToString("g"));Console.WriteLine(dateOnly.ToString("MM/dd/yyyy HH:mm")); // The example displays the following output to the console:// 6/1/2008 7:47:00 AM// 6/1/2008// 6/1/2008 12:00 AM// 06/01/2008 00:00

![从C#中的DateTime中提取日期部分[重复] 从C#中的DateTime中提取日期部分[重复]](http://www.mshxw.com/aiimages/31/372107.png)
