Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Inchour function
Tue, Apr 4 2017 10:19 AMPermanent Link

Huseyin Aliz

myBiss ApS

Avatar

Hi All,

Can anyone please help with following to make it work with hours?

function IncDay(const aValue: DateTime;aNumberOfDays:integer=1):DateTime;
begin
Result:=aValue;
if aNumberOfDays>0 then
  begin
Result:=EncodeDateTime(YearOf(aValue),MonthOf(aValue),DayOf(aValue),0,0,0,0)+((aNumberOfDays*MillSecDay)+(2*MillSecHour));
Result:=EncodeDateTime(YearOf(Result),MonthOf(Result),DayOf(Result),0,0,0,0);
  end;
end;

I want to change datetime field with hours instead of days Smile

Thanks in advance.

Hüseyin

Tue, Apr 4 2017 10:24 AMPermanent Link

Matthew Jones

Hüseyin Aliz wrote:

> Can anyone please help with following to make it work with hours?

function IncMinute(tmWhen : DateTime; nMinutes : Integer) : DateTime;
begin
   Result := tmWhen + (nMinutes * 60 * 1000);
end;

function IncSecond(tmWhen : DateTime; nSeconds : Integer) : DateTime;
begin
   Result := tmWhen + (nSeconds * 1000);
end;

function IncMilliSecond(tmWhen : DateTime; nMilliseconds : Integer) : DateTime;
begin
   Result := tmWhen + nMilliseconds;
end;

function IncHour(tmWhen : DateTime; nHours : Integer) : DateTime;
begin
//    Result := tmWhen + (nHours * 1000 * 60 * 60);
   Result := tmWhen + (nHours * 3600000);
end;

--

Matthew Jones
Tue, Apr 4 2017 11:45 AMPermanent Link

Huseyin Aliz

myBiss ApS

Avatar

Matthew,

Thanks Smile

Regards,

Hüseyin


Den 04-04-2017 kl. 16:24 skrev Matthew Jones:
> Hüseyin Aliz wrote:
>
>> Can anyone please help with following to make it work with hours?
> function IncMinute(tmWhen : DateTime; nMinutes : Integer) : DateTime;
> begin
>      Result := tmWhen + (nMinutes * 60 * 1000);
> end;
>
> function IncSecond(tmWhen : DateTime; nSeconds : Integer) : DateTime;
> begin
>      Result := tmWhen + (nSeconds * 1000);
> end;
>
> function IncMilliSecond(tmWhen : DateTime; nMilliseconds : Integer) : DateTime;
> begin
>      Result := tmWhen + nMilliseconds;
> end;
>
> function IncHour(tmWhen : DateTime; nHours : Integer) : DateTime;
> begin
> //    Result := tmWhen + (nHours * 1000 * 60 * 60);
>      Result := tmWhen + (nHours * 3600000);
> end;
>
Image