Click to See Complete Forum and Search --> : DateTime adding time


roncdaf
November 20th, 2006, 04:42 AM
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

stardv
November 20th, 2006, 10:12 AM
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());

AlanGRutter
November 20th, 2006, 04:46 PM
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