|
-
November 20th, 2006, 05:42 AM
#1
DateTime adding time
Hello
Ive got 2 strings in this format "01-01-2006 00:00:00" and "14:23:23". First is the date and second the time. I would like to put them into 1 DateTime.
It seems obvious to parse them to DateTime and then add the time to the date using .AddHours etc.
But the functions AddHours, AddMinutes and AddSeconds dont seem to work. Im putting the correct value in them but the time doestnt change.
Anyone knows if these functions just dont work, or if im doing something wrong. I have no clue.
thx
-
November 20th, 2006, 11:12 AM
#2
Re: DateTime adding time
Another thing you can is pars one as date , another as time , concatenate it and pars as datetime, something like this
DateTime.Parse(datestring.ToShortDateString() + " " + timestring.ToShortTimeString());
"We act as though comfort and luxury were the chief requirements of
life, when all that we need to make us happy is something to be
enthusiastic about."
- Einstein
-
November 20th, 2006, 05:46 PM
#3
Re: DateTime adding time
I have used AddHours etc without any problems in my code so they do work.
As always it is impossible to tell what you may be doing wrong unless you actually post your code.
Regards
Alan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|