Using data from a formula for a parameter

If i have two formula fields which calculate the dateDiff's of two dates by days, how can I use the data from both formulas as a single parameter?

Example:

Doc A Days between Start and stop:  70
Doc B Days between Start and Stop: 30

User needs to see all records that fall between 25 and 55 days and it needs to be pulled records need to be shown from both tables.
LVL 1
Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
What are the formulas?

Are the tables joined?

mlmcc
Author Commented:
The tables are Left joined to a patient table. The formulas show the difference between two dates producing a number.

Formula 1 Start Stop:
``````if {pt_docs.template_file}='Doc A' then {signoff_hx.create_timestamp}-{@admitdate}-30
else
if {pt_docs.template_file}='Doc B'  then {signoff_hx.create_timestamp}-{@lastHistory}-90
``````

Formula 2 Start Stop:
Basically the same as one, but more logic involved which selects the most recent date from a possible 7. The end result is:
CurrentDate-{@nextDueDate}
Author Commented:
I just rethought this, although it may be the same logic ultimately.

Instead of numbers, somehow I would need to have two due dates from two different fields fall into one parameter and show results based on the one parameter.
Commented:
So the formula calculates the DateSigned Off - Date Created.  What is the -30  is that also sutracting?

How about the other one where the number is 90?

Since it says time stamp, is that a date time type or an integer for the number of seconds?

You want to see any that are Date Signed Off - Date Created > 25 and Date Signed Off - Date Created < 55?

mlmcc
Author Commented:
The -30 takes away 30 days from DateSigned Off - Date Created and -90 from another calculation.

it's a datetime type.

The user will need to enter a date range and see how many patients show as a result. The results need to fall within the users entered date range. so they will use the parameter to select two dates and then see the results, if possible.
Commented:
Ignoring the 25 to 55 days from your first post and the days between dates calculations, if you just want to compare a date range entered by the user to two date fields, you could just use:

{date field 1} = {?date range parameter} and
{date field 2} = {?date range parameter}

Use AND to get the records where both fields are in the range, or OR to get the records where either field is in the range.

But I'm guessing that what you're really looking for is not that simple.

James
Author Commented:
James.

The date fields are calculated within a formula. I would need to use those dates within the parameter, which doesn't seem easily possible. Any ideas how I can do that?
Commented:
Depends on the formula.

What formula are you trying to use?

You cannot use a printtime formula so it cannot have WhilePrintingRecords or shared variables

mlmcc
Author Commented:
The date formulas don't have WhilePrintingRecords or shared variables. The formulas simply evaluate a set of date fields and choose the latest one, then add 30 or 90 days onto them.
Author Commented:
instead of going extra fancy, I used a group which shows different time intervals based on the combined formulas. Any ideas to solve this issue otherwise?
Commented:

mlmcc
Commented:
As mlmcc said, it depends on what you're doing in the formula(s).  For example, you posted this earlier:

else
if {pt_docs.template_file}='Doc B'  then {signoff_hx.create_timestamp}-{@lastHistory}-90

Assuming that @admitdate and @lastHistory produce a date/datetime result, then that formula just produces a number (the number of days between two dates, minus 30 or 90), so you can't compare that to a date.  But you could, for example, add the result of that formula to some date and compare that to another date; or take the difference between two other dates and compare that difference to the result from that formula.

If you want to compare the results from a formula like that with a date range that the user enters, how is the comparison supposed to work?  What are you really trying to compare?

OTOH, if @admitdate and @lastHistory actually produce a numeric result, the formula above would produce a date/datetime result (create_timestamp minus X number of days).

James

Experts Exchange Solution brought to you by