Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Parameter to UFL 1

Status
Not open for further replies.

dugjohnson

Programmer
Aug 5, 2002
7
US
I am writing a UFL that figures lag time between a customer contact and response by tech support, pulling out non-working days.
One of my functions
Boolean: IsBusinessDay(Date)
takes a date as a parameter. As a test I am passing it CDate('01/01/2004') which is showing up in Delphi as 2453005 and translates to a date sometime in the year 8214.
How are dates passed to a UFL (it appears to be a long integer) and how does it translate to a date? My understanding was that it was the number of days after 12/31/1899, but that does not appear to be the case. Thanks in advance.
Doug
P.S. I have written UFLs with string parameters to good effect so I assume my basic technique is OK...time to branch out.
 
An interesting approach, however creating a Periods table is the industry standard, a required dimension for Data Marts, which eliminates the requirement for writing and maintaining code for this sort of thing, and much more:

faq767-4532

-k
 
And if I controlled the horizontal and vertical of this internal app, I would do that. This function is just one of several that I am working on.
I am still in the dark as to how a date is passed to a UFL.
Doug
 
I seem to recall that the date that is passed is a Julian date so you need to convert using a Julian Date offset. Here's a function that I wrote to tell me if a date is within a month:

Code:
const
  JulianDateOffset = 2415018;

<snip>

function InMonth (ParamBlock : PUFParamBlock) : UFError;
var 
     Param1 : PUFParamListElement; //a pointer to the first parameter
     Param2 : PUFParamListElement; //a pointer to the second parameter
     D1     : UFTDate;
     D2     : UFTDate;

     i      : boolean;

begin

     Param1 := GetParam (ParamBlock, 1); //the first param is the string to trim
     Param2 := GetParam (ParamBlock, 2); //the second param is the character to trim

     //check if the correct number of parameters is passed to our function

     if (Param1 = nil) or (Param2 = nil) then
     begin

         Result := UFNotEnoughParameters;
         EXIT;
         
     end;

     //is the param1 date in the same month as the param2 date?

     D1 := Param1^.Parameter.ParamDate - JulianDateOffset;
     D2 := Param2^.Parameter.ParamDate - JulianDateOffset;

     i := false;
     
     if Year(D1) = Year(D2) then 
         if Month(D1) = Month(D2) then
             i := true;

     ParamBlock^.ReturnValue.ReturnBoolean := smallint(i);

     result := UFNoError;
end;

Good luck!

Django
 
Django, you rock. That is exactly the info that I needed. The other info on how to redesign futures apps was also valuable for my brain needs, but this solved the current emergency.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top