Need date part of datetime variable

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
 
T

tshad

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top