How to format datetime?

  • Thread starter Thread starter Vinitha
  • Start date Start date
V

Vinitha

Hi,
I 've ("9/27/2003 12:11:31 PM") this value in database .
i need to get only this value ("9/27/2003 " ) .How will i format it to get
this value?

It will be helpful if some one could point me to some code sample for the
same

thank you in advance
 
Hi

Construct new Datetime values from value in database
DateTime dt = new DateTime(databasevalue)
then use dt.Date.

HTH
Ravikanth[MVP]
 
if you want string, you can use:

DateTime aDateTime = getDateTimeFromDB(some criteria);
string str = aDateTime.Value.ToShortDateString();
 
Vinitha said:
Hi,
I 've ("9/27/2003 12:11:31 PM") this value in database .
i need to get only this value ("9/27/2003 " ) .How will i format it to get
this value?

It will be helpful if some one could point me to some code sample for the
same

thank you in advance

DateTime theDate .....
theDate.ToString("m/d/yyyy");

if it is the string representation that you want.
 
Back
Top