WbemScripting.SWbemDateTime не всегда работает. Лучший способ:
function WmiDate2DT (S: string; var UtcOffset: integer): TDateTime ;
// yyyymmddhhnnss.zzzzzzsUUU +60 means 60 mins of UTC time
// 20030709091030.686000+060
// 1234567890123456789012345
var
yy, mm, dd, hh, nn, ss, zz: integer ;
timeDT: TDateTime ;
function GetNum (offset, len: integer): integer ;
var
E: Integer;
begin
Val (copy (S, offset, len), result, E) ;
end ;
begin
result := 0 ;
UtcOffset := 0 ;
if length (S) <> 25 then exit ; // fixed length
yy := GetNum (1, 4) ;
mm := GetNum (5, 2) ;
if (mm = 0) or (mm > 12) then exit ;
dd := GetNum (7, 2) ;
if (dd = 0) or (dd > 31) then exit ;
if NOT TryEncodeDate (yy, mm, dd, result) then // D6 and later
begin
result := -1 ;
exit ;
end ;
hh := GetNum (9, 2) ;
nn := GetNum (11, 2) ;
ss := GetNum (13, 2) ;
zz := 0 ;
if Length (S) >= 18 then zz := GetNum (16, 3) ;
if NOT TryEncodeTime (hh, nn, ss, zz, timeDT) then exit ; // D6 and later
result := result + timeDT ;
UtcOffset := GetNum (22, 4) ; // including sign
end ;
function VarDateToDateTime(const V: OleVariant): TDateTime;
var
rawdate: string ;
utcoffset: integer ;
begin
Result:=0;
if VarIsNull(V) then exit;
Dt.Value := V;
try
Result:=Dt.GetVarDate;
except
rawdate:=V;
result := WmiDate2DT (rawdate, utcoffset);
end;
end;