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
2009-05-12 04:37:35
+2
A:
you can do it this way:
DateTime.Parse("23/9/2009 10:00:00").Date.ToString()
Marwan Aouida
2009-05-12 04:37:41
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
2009-05-12 04:50:17
+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
2009-05-12 04:39:33