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

Comparing Dates 2

Status
Not open for further replies.

LDickenson

IS-IT--Management
Jun 11, 2007
27
Hi

I have a report that has 5 dates and I need a report to display the latest date i.e.

date2 > date1 then put in date2 or
if date3 > date2 then put in date3 else
date1

Can anyone help with this.

Thanks,
Lisa
 
Just build a formula based upon your summary

If Date3 > date2 and date3> date1 then date3
else
if date2> date1 then date2
else date1

Ian
 
If you mean these are all separate date fields, then you can use a formula like this:

maximum([{table.date1},{table.date2},{table.date3}])

-LB
 
Thanks that is brilliant the maximum worked the next step I have to do it dependant on the date that is the maximum it has another field attached to it e.g.

IF date2 is maximum then outcome2 else
IF date3 is maximum then outcome3 etc

Thanks,

Lisa
 
Probably best to use LB's solution

IF date2 = maximum([{table.date1},{table.date2}, table.date3}]) then outcome2
else
IF date3 = maximum([{table.date1},{table.date2}{table.date3}])then outcome3
else outcome1

Not sure what you will do if any of the dates are the same?

Ian
 
Hi

I am using the following formula


maximum ([{Table.date1}, {Table.date2}, {Table.date3}])


But it is only returning data if I have something in date 3, if I have a date in date1 and nothing in 2 and 3 then it is blank the same with date2.

Thanks,

Lisa
 
Unfortunately crystal formula fail if they encounter nulls.

Replcae the datefields with 3 formula

@date1

If isnull(date1) then date(1900, 01, 01) else date1

Repaet for each date and then use these in LB's solution

maximum({@Date1}, {@date2}, {@date3})

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top