tags:

views:

551

answers:

4

hi guys, I have a datetime for eg:23/9/2009 10:00:00 AM .I want to get date from datetime.Means 23/9/2009 .Can anybody help

+1  A: 

Searching the web always helps.

Google 'datetime msdn' and you'll get the best reference material.

Gabriel Florit
+2  A: 

you can do it this way:

DateTime.Parse("23/9/2009 10:00:00").Date.ToString()
Marwan Aouida
There are two problems with your code; it will throw an exception if it's run in another locale than US (or one that has the same date format), and it will print the 00:00:00 for the time.
Fredrik Mörk
+6  A: 

Just do

DateTime dateOnly = myDateTime.Date;

To display it as a date you can do

string dateString = dateOnly.ToShortDateString();

Note, that ToShortDateString will work even with a time component.

Steven
+1  A: 

Yeah, the .Date property will give you what you need.

Gromer