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!

Find the earliest date from a selection of fields CR8.5

Status
Not open for further replies.

Phil99

Programmer
Jul 12, 2002
32
GB
Hi,

I'm sure this is easy but I'm very new to crystal.

A record will contain date fields A, B, C. I need to compare the fields and pick up the earliest date.

I've used a formula field to print the date but am not sure how to use variables within a formula.

The function will then be:
local datetimevar vdate
if A is not null
vDATE = A
if B is not null and B < VDATE
VDATE = B
if C is not null and C < VDATE
VDATE = C

How do a then return VDATE as the formula field value???

Thanks

Phil



 
You pretty much have it:

local datetimevar vdate
if A is not null
vDATE := A;
if B is not null and B < VDATE
VDATE := B;
if C is not null and C < VDATE
VDATE := C;
vdate

If you don't need to check nulls in your tables, you can use the setting File->Report Options->Convert null field value to default, that way there won't ever be a null to worry over.

I've heard many here state that they never check this, but if you aren't really using nulls, it saves worrying over the oddities Crystal throws at you when using Nulls, and there are plenty...

Then your formula would be
local datetimevar vdate
vDATE := A;
if B < VDATE
VDATE := B;
if C < VDATE
VDATE := C;
vdate


-k kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top