Board index » delphi » UDF Date parameter passing

UDF Date parameter passing


2007-02-25 12:55:38 AM
delphi162
Hi,
I need a IncrementDate function that (simplified) adds a
certain time period to a StartDate. I am using Delphi and
have tried something like:
TMyDate = record
DateHigh: LongInt;
DateLow: LongWord;
end;
PMyDate = ^TMyDate;
function IncrementDate(StartDate: PMyDate; var
IncrementFactor: integer): PMyDate; stdcall;
implementation:
function IncrementDate(StartDate: PMyDate; var
IncrementFactor: integer): PMyDate; stdcall;
var StartDateTime, ResultDateTime: TDateTime;
begin
StartDateTime := StartDate.DateHigh;
case IncrementFactor of
1: ResultDateTime := int_AddYear(StartDateTime,1);
...
else ResultDateTime := StartDateTime;
end;
Result := @ResultDateTime
end;
Am I on the right track?
/Martin
 
 

Re:UDF Date parameter passing

Is there a reason you cannot use the IncMonth, IncDay, IncYear,
IncHour,... functions in the Delphi RTL? See DateTime Funcitons in the
on line help.
--
Bill Todd (TeamB)
 

Re:UDF Date parameter passing

Hi Bill,
I am writing a UDF for use with IB/FB, but I guess you noticed that from the title. So the question is not really about the implementation, but about the passing of params and different Date type conversions.
As for the implementation, it is for a financial application, and I have to cater for the two different years in this area: 365 or 360 days. But as said, this is the implementation.
/Martin
"Bill Todd" <XXXX@XXXXX.COM>writes:
Quote
Is there a reason you cannot use the IncMonth, IncDay, IncYear,
IncHour,... functions in the Delphi RTL? See DateTime Funcitons in the
on line help.

--
Bill Todd (TeamB)
 

Re:UDF Date parameter passing

Martin writes:
Quote
I am writing a UDF for use with IB/FB, but I guess you noticed that
from the title. So the question is not really about the
implementation, but about the passing of params and different Date
type conversions.
I saw the title but did not see anything about UDFs in the body of the
message so I just guessed at what your question really was. There are a
couple of very good articles on BDN about writing UDFs. Hopefully they
will answer your questions. I have not written a UDF for a long time
and I am not sure I have ever done one that passes dates so I would
have to research how to do it.
--
Bill Todd (TeamB)
 

Re:UDF Date parameter passing

OK, thanks anyway. I have of course googled for info on
passing date params, but there seems not to be so very much
around. I will have a look at BDN too.
/M
"Bill Todd" <XXXX@XXXXX.COM>writes:
Quote
Martin writes:

>I am writing a UDF for use with IB/FB, but I guess you noticed that
>from the title. So the question is not really about the
>implementation, but about the passing of params and different Date
>type conversions.

I saw the title but did not see anything about UDFs in the body of the
message so I just guessed at what your question really was. There are a
couple of very good articles on BDN about writing UDFs. Hopefully they
will answer your questions. I have not written a UDF for a long time
and I am not sure I have ever done one that passes dates so I would
have to research how to do it.

--
Bill Todd (TeamB)
 

Re:UDF Date parameter passing

Martin writes:
Quote
OK, thanks anyway. I have of course googled for info on
passing date params, but there seems not to be so very much
around. I will have a look at BDN too.
See dn.codegear.com/article/27134
--
Bill Todd (TeamB)
 

Re:UDF Date parameter passing

You could check out FreeUDFLib by Gregory Deatz. I found this very useful.
The source for this DLL gives some examples of using dates, and it is not
too difficult to extend them as you require - and it also includes existing
functions to eg AddMonth and AddYear et al.
--
Brent Rose
Whats On Report
XXXX@XXXXX.COM