dateTime addition

S

simon

I have :

dateTime dateFinal;
DateTime dateFirst;
string startTime;

startTime="2:02:05";

dateFirst="22.08.2005 0:00:00";(read this value from some control)

How can I get the date from dateTime and string variable?

Something like this:

dateFinal=dateFirst+startTime;

dateFinal should be: "22.08.2005 2:02:05"

regards,S
 
G

gmiley

you could use the following (though I am sure there must be a better
way):

string startTime = "2:02:05";
DateTime firstDate = DateTime.Today;
DateTime finalDate = DateTime.Parse(firstDate.Date.ToString() + " " +
startTime);
 
C

Charlieee

Simon try:

String theDate = dateFirst.Day.ToString();
or
String theDate = Convert.ToString(dateFirst.Day);

Charlie
:)
 

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