Need date part of datetime variable

  • Thread starter Thread starter tshad
  • Start date Start date
T

tshad

I can't seem to get the Date portion of a datetime variable put into a
string:

I tried:

DateTime dateTime;
dateTime = Convert.ToDateTime(dr[ktr][1]).Date;
stemp = Convert.ToString(dateTime);

This will give me "5/5/2006 12:00:00 AM"

I only want the "5/5/2006" portion.

Thanks,

Tom
 
MSDN said:
dateTime.ToShortDateString

That did it.

Thanks,

Tom
tshad said:
I can't seem to get the Date portion of a datetime variable put into a
string:

I tried:

DateTime dateTime;
dateTime = Convert.ToDateTime(dr[ktr][1]).Date;
stemp = Convert.ToString(dateTime);

This will give me "5/5/2006 12:00:00 AM"

I only want the "5/5/2006" portion.

Thanks,

Tom
 
Back
Top