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

Maximum Date <= CurrentDate 1

Status
Not open for further replies.

southbean

Technical User
Jun 3, 2005
147
US
Hello All,

I’m using a table that has five date fields per record. I need to create a formula that finds the greatest date that is < = CurrentDate. I tried this formula (below) but I discovered it returns a Null value if any of the five date fields are Null.
Code:
Maximum([{Table.Date1},{ Table.Date2},{ Table.Date3},
        { Table.Date4},{ Table.Date5}])

I suspect an Array is in order here. But how do I do that?

Also, In the above formula I tried to add the “< = CurrentDate” at the end, but it returned a “True” or “False” value.

I obviously don’t know what I’m doing here. Any/all help would be greatly appreciated!!!
- t
 
What version of Crystal?

You might try under file, options,and check the "Convert null values to default" checkbox on the reporting tab.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
Hi dgillz,

Thanks for your reply. I enabled the "Convert null values to default" check box, but it had no effect on the result.
Would welcome any other suggestions!

Thanks again,

-t
 
Like you've ascertained, if the code encounters a null and you haven't handled it, it'll just drop out.

Explicitly handle your nulls. There's a number of ways you can do this. The following is an example of one:

maximum([(if isnull({table.date1}) then date(1900,1,1) else {table.date1}),same for date2,same for date3,etc])

Naith
 
Naith,

Thank you very much!!! Just what I needed to get started. I'm still not familiar enough with Crystal syntax to get through issues like this. That's why this forum is SO great for newbies like me.

Thanks again!!!

-t
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top