#1 2015-06-18 08:34:00

noobies
Member
Registered: 2011-09-13
Posts: 139

TTimeLog and Get Year SQL command

if i use InputDate: TDateTime i write

  Result := sql + FormatUTF8('strftime("%Y", InputDate) = ?', ['%'], [y]);

but if i use Created: TTimeLog how get all records only 2015 year?

Offline

#2 2015-06-18 10:10:44

noobies
Member
Registered: 2011-09-13
Posts: 139

Re: TTimeLog and Get Year SQL command

i found solution from source

{$ifdef MSWINDOWS}
procedure TTimeLogBits.Expand(out Date: TSystemTime);
begin
  Date.wYear := (Value shr (6+6+5+5+4)) and 4095;
  Date.wMonth := 1+(Int64Rec(Value).Lo shr (6+6+5+5)) and 15;
  Date.wDay := 1+(Int64Rec(Value).Lo shr (6+6+5)) and 31;
  Date.wDayOfWeek := 0;
  Date.wHour := (Int64Rec(Value).Lo shr (6+6)) and 31;
  Date.wMinute := (Int64Rec(Value).Lo shr 6) and 63;
  Date.wSecond := Int64Rec(Value).Lo and 63;
end;
{$endif}

work solution (y must be integer)

Result := sql + FormatUTF8('(r.Created >> (6+6+5+5+4)) & 4095 = ?', [], [y]);

or if y string

  Result := sql + '(r.Created >> (6+6+5+5+4)) & 4095 = ' + y;

Last edited by noobies (2015-06-18 10:11:33)

Offline

#3 2015-06-18 14:58:25

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Offline

Board footer

Powered by FluxBB