FireGeek21
Technical User
I have a couple formula fields I am trying to use so I can calculate the number of days that have lapsed. This is working to a point - if other records are edited or changed after a status of 1, it's picking up these later dates and not the status of 1 date. If after a status of 1, other records are edited or changed, I only want the date returned for a status of 1 (minimum date). If there is no status of 1, then I want the maximum date. Clear as mud? Here are my formulas...
{@REQ_DT}:
Date({ReqTable.DateField})
{@STATUS_DT}:
Date({HxTable.DateField})
{@MAX_STATUS_DT}:
IF {HxTable.Status} = 1 THEN Date({HxTable.DateField})
ELSE Maximum({@Status_DT, {ReqTable.REQ})
{@Days_Open}:
DateDiff('d', {@REQ_DT}, {@MAX_STATUS_DT})
Data sample:
Req Req_DT Status Status_DT
123 01/01/2010 4 01/03/2010
123 01/01/2010 3 01/06/2010
123 01/01/2010 7 01/10/2010
345 02/15/2010 4 02/15/2010
345 02/15/2010 3 02/20/2010
345 02/15/2010 1 02/25/2010
345 02/15/2010 7 08/01/2010
567 03/01/2010 3 03/02/2010
567 03/01/2010 1 03/26/2010
In Req 123, I would like DateDiff to calculate as:
DateDiff('d', 01/01/2010, 01/10/2010) = 10
In Req 345, I would like DateDiff to calculate as:
DateDiff('d', 02/15/2010, 02/25/2010) = 10 (don't use 08/01/2010)
In Req 567, I would like DateDiff to calculate as:
DateDiff('d', 03/01/2010, 03/26/2010) = 25
It's like I need the minimum(maximum(status_dt))???
Thanks for the help!
FireGeek
(currently using Crystal Reports XI with Lawson 8.03)
{@REQ_DT}:
Date({ReqTable.DateField})
{@STATUS_DT}:
Date({HxTable.DateField})
{@MAX_STATUS_DT}:
IF {HxTable.Status} = 1 THEN Date({HxTable.DateField})
ELSE Maximum({@Status_DT, {ReqTable.REQ})
{@Days_Open}:
DateDiff('d', {@REQ_DT}, {@MAX_STATUS_DT})
Data sample:
Req Req_DT Status Status_DT
123 01/01/2010 4 01/03/2010
123 01/01/2010 3 01/06/2010
123 01/01/2010 7 01/10/2010
345 02/15/2010 4 02/15/2010
345 02/15/2010 3 02/20/2010
345 02/15/2010 1 02/25/2010
345 02/15/2010 7 08/01/2010
567 03/01/2010 3 03/02/2010
567 03/01/2010 1 03/26/2010
In Req 123, I would like DateDiff to calculate as:
DateDiff('d', 01/01/2010, 01/10/2010) = 10
In Req 345, I would like DateDiff to calculate as:
DateDiff('d', 02/15/2010, 02/25/2010) = 10 (don't use 08/01/2010)
In Req 567, I would like DateDiff to calculate as:
DateDiff('d', 03/01/2010, 03/26/2010) = 25
It's like I need the minimum(maximum(status_dt))???
Thanks for the help!
FireGeek
(currently using Crystal Reports XI with Lawson 8.03)