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!

formula for time between activity codes

Status
Not open for further replies.

ChipF

Technical User
Nov 15, 2002
50
US
What is the formula syntax to show the time between an SO and SA activity code? So I want something like this:

If {DLY_ACTIVITY.ACTIVITY_CD}= "SA" then
SA{DLY_ACTIVITY.ACTIVITY_DT} - SO{DLY_ACTIVITY.ACTIVITY_DT}
else 0

 
In Crystal 8.5, you need something like this
DateDiff ("d", {DLY_ACTIVITY.ACTIVITY_DT}, SO_DATE)

This gives the difference in days, there are other options. Getting the two dates in the same section is not so straightforward, it depends on your data. You do have Next and Previous commands for records, or you can group and find the maximum and minimum values.

Madawc Williams
East Anglia, Great Britain
 
If there is only one "SA" and one "SO" per group (assuming you are grouping), then you could just use the next or previous function:

if {table.groupfield} = next({table.groupfield}) then
next({DLY_ACTIVITY.ACTIVITY_DT})-{DLY_ACTIVITY.ACTIVITY_DT}

Another option would be to add the table twice and for one table limit the activity types to "SA" and for the other, limit the types to "SO". Then you could easily subtract the two.

If you have multiple instances of each type, you might want to try the second approach and compare maximums or minimums of each field, although it's hard to tell what your goal is here. Maybe provide more sample data and explain what you are trying to achieve.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top