Re: ShortDateFormat Problem
- From: "alanglloyd@xxxxxxx" <alanglloyd@xxxxxxx>
- Date: 19 Sep 2006 08:23:04 -0700
originalflo@xxxxxxxxx wrote:
Hi there,
if there are common formats as 'dd.mm.yy' there is no problem
e.g.
MyDate := '22.08.06';
MyTime := '07:43:39';
ShortDateFormat := 'dd.mm.yy';
DateSeparator := '.';
ShortTimeFormat := 'hh:nn:ss';
TimeSeparator := ':';
MyDt := StrToDateTime( MyDate + ' ' + MyTime ); // it works fine
now I have the Problem that i get the Date/Time Values in the following
format:
MyDate := '220806';
MyTime := '074339';
ShortDateFormat := 'ddmmyy';
DateSeparator := ''; // doesn't compile: E2010 incompatible
types: 'Char' and 'string'
ShortTimeFormat := 'hhnnss';
TimeSeparator := ''; // doesn't compile: E2010 incompatible
types: 'Char' and 'string'
if I set the DateSeparator and the TimeSeparator to '0':
MyDt := StrToDateTime( MyDate + ' ' + MyTime ); // raises an
EConvertError
if I set the Separators to nil i get an E2010 incompatible types:
'Char' and Pointer
how can I solve this problem?
1 Use the correct date & time formats.
2 Insert the date or time separators ...
function InsertTimeSeparator(TimeStr : string) : string;
var
LenTimeStr : integer;
begin
SetLength(Result, 8);
try
LenTimeStr := Length(TimeStr);
if LenTimeStr <> 6 then
Raise EConvertError.Create('TimeStr wrong length : ' +
InttoStr(LenTimeStr));
Result[1] := TimeStr[1];
Result[2] := TimeStr[2];
Result[3] := TimeSeparator;
Result[4] := TimeStr[3];
Result[5] := TimeStr[4];
Result[6] := TimeSeparator;
Result[7] := TimeStr[5];
Result[8] := TimeStr[6];
except
on E: Exception do
ShowMessage(E.Message);
end;
end;
3 Write your own MyTimeStrToTime() function.
Alan Lloyd
.
- References:
- ShortDateFormat Problem
- From: originalflo
- ShortDateFormat Problem
- Prev by Date: Re: ShortDateFormat Problem
- Next by Date: Re: ShortDateFormat Problem
- Previous by thread: Re: ShortDateFormat Problem
- Next by thread: Re: ShortDateFormat Problem
- Index(es):
Relevant Pages
|