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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Minimum date between two date fields

Status
Not open for further replies.

Almie

Technical User
Nov 28, 2006
39
US
Running CR10 against a Informix database.
In my main report, I have a sentence date, where date can be null. In my subreport, I have a receipt date, with receipts date can be null. I've created a shared variable to pull the receipt date and placed the formula in the group footer.

I need to find the minimum date between the sentence date and the receipt date.

Addressing the null date values:
If sentence date is null, the receipt date would be the minimum date. If receipt date is null, the sentence date would be the minimum date.


Can anyone help?
 
Assumming there's only one sentence date per group:

whileprintingrecords;
shared datevar {@receiptdate};
if isnull({@receiptdate})
and
isnull({table.sentencedate}) then
"N/A"
else
if isnull({@receiptdate})
and
not(isnull({table.sentencedate})) then
{table.sentencedate}
else
if isnull({table.sentencedate}) then
and
not(isnull({@receiptdate})) then
{@receiptdate}
else
if {@receiptdate} <= {table.sentencedate} then
{@receiptdate}
else
{table.sentencedate}

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top