omsec
asked on
TDateTime
Hi,
I have a problem with "mixing" a Date (given from a TMonthCalendar) and a Time (given indirectly from a TEdit) to one TDateTime-Value.
The MonthCalendar returns a TDateTime-Value with the current or specified Date (which is good) and also with the current Time (which is no good)
eg. 25.04.00, 15:54:00
and the StrToTime(Edit1.Text) returns the Time only (which is enough for me)
31.12.1899 (or something), 16:00:00
but when i simply add those two DateTime-Values I get something completly weird. So how would i mix the Date from the MonthCalendar with the Time from the Editbox to
25.04.00, 16:00:00
I think it cant be that hard, but im not really familiar with TDateTime...
I have a problem with "mixing" a Date (given from a TMonthCalendar) and a Time (given indirectly from a TEdit) to one TDateTime-Value.
The MonthCalendar returns a TDateTime-Value with the current or specified Date (which is good) and also with the current Time (which is no good)
eg. 25.04.00, 15:54:00
and the StrToTime(Edit1.Text) returns the Time only (which is enough for me)
31.12.1899 (or something), 16:00:00
but when i simply add those two DateTime-Values I get something completly weird. So how would i mix the Date from the MonthCalendar with the Time from the Editbox to
25.04.00, 16:00:00
I think it cant be that hard, but im not really familiar with TDateTime...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
the neil, you just said it
dtTime := StrToTime(Edit1.Text);
dtDate := MonthCalendar.Date;
dtFinal := TRUNC(dtDate) + (FRAC(dtTime));
meikl
dtTime := StrToTime(Edit1.Text);
dtDate := MonthCalendar.Date;
dtFinal := TRUNC(dtDate) + (FRAC(dtTime));
meikl
Either I got it right or there's someone else out there as confused and lost as I am
The Neil =;)
PS. Thanks for pointing out FRAC - I didn't know about that
The Neil =;)
PS. Thanks for pointing out FRAC - I didn't know about that
U can try this;
strTime:string;
strDate:string;
dtFinal : TDateTime;
strTime := Edit1.Text;
strDate := DateToStr(MonthCalendar.Da te);
dtFinal := StrToDateTime(strDate + ' ' + strTime);
strTime:string;
strDate:string;
dtFinal : TDateTime;
strTime := Edit1.Text;
strDate := DateToStr(MonthCalendar.Da
dtFinal := StrToDateTime(strDate + ' ' + strTime);
ASKER
i think theNeil gave me the pointer :)
I'm gonna test it now...
I'm gonna test it now...
ASKER
CoreEye: The solution using numeric data types only might be more efficient since the CPU proceeds operations faster on these types than it does on strings - TheNeil's code does the job fine and quickly and he posted his text first, i think he deserved the points, altought it's not much :)
Thanks Omsec. All points gratefully received
The Neil =;)
The Neil =;)
Try that...