Print Page | Close Window

Date Diff in Same Column for Each Group

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=17200
Printed Date: 29 Apr 2024 at 2:25am


Topic: Date Diff in Same Column for Each Group
Posted By: dirtypotato
Subject: Date Diff in Same Column for Each Group
Date Posted: 02 Aug 2012 at 12:20pm
Hi,
I am trying to write a formula to calculate the Date Diff between my start dates.  I only want the report to calculate "Days Since Last Shot" for each group(Client).  So i don't want to see the Difference in days between the last record of the previous group.  So in the second group, i dont want to see 169, i want to see 0, but i do want to see the 68 on the next line.   Does this make sense?

Here is what i am using now for my formula:
if not onfirstrecord then
DateDiff ("d",{StartDate},(PREVIOUS({StartDate})))





-------------
Nate



Replies:
Posted By: dirtypotato
Date Posted: 02 Aug 2012 at 12:24pm
Oops there was a screen shot to go with this, guess that doesn't work...

Here is my example:

Group 1

Start Date              Days Since Last Shot
1/20/2011              1
1/20/2011              1

Group 2

Start Date              Days Since Last Shot
8/4/2010                169
5/25/10                  68
5/25/10                  0



-------------
Nate


Posted By: dirtypotato
Date Posted: 02 Aug 2012 at 12:37pm
got it....

if (previous ({ID}))={ID} then
DateDiff ("d",{StartDate},(PREVIOUS({StartDate})))


-------------
Nate



Print Page | Close Window