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

Datediff Same Column and Previous in Same Record 1

Status
Not open for further replies.

gordabella25

Technical User
Jan 19, 2011
11
US
I am new to Crystal Reports and trying to use "Datediff" in the same column, so I's using "Previous" as well but I need this formula to run only for the current record not the previous one. How can i make this work?

Here is the syntax I'm using:

(DateDiff("d",{Issues.IssueItems~Date}, (PREVIOUS ({Issues.IssueItems~Date}))))

can anyone please help me!

Thanks!
 
The current record will be the previous one on the next record.

If you do not want it to run on the first record try

If not onfirstrecord then
(DateDiff("d",{Issues.IssueItems~Date}, (PREVIOUS ({Issues.IssueItems~Date}))))

Ian
 
Ian,

Thanks for your quick response, what i need is that the formula to run ONLY in ONE record at time not the previous one, I'm using 'previous" to be able to use datediff in the same column - perhaps i need to use or add something else??

Thanks again!
 
Still not sure what you mean.

But if you have a condition which determines which record to run formula add that to the If condition.

Alternatively suppress formula for alternate rows.

Ian
 
There are 18 records in my database - i want this formula to be evaluated only in one record at time - in other words i don't want to evaluate ({Issues.IssueItems~Date} with ({Issues.IssueItems~Date} from the previous record but to evaluate ({Issues.IssueItems~Date} for same record but previous row
 
Please understand that technically a record IS a row. You need to clarify what is distinguishing the record/row you want displayed from those you don't. By "record" are you referring to an account of some type that has multiple records?

-LB
 
Not sure if this will help...

Sample of my data:

Status Date Previous Date DateDiff
03/06/2010 0
04/09/2010 03/06/2010 34
04/15/2010 04/09/2010 6

Status Date is a field in my table.

Previous Date =
WhilePrintingRecords;
IF (table.idfield) = Previous(table.idfield) THEN Previous(table.statusdate);

DateDif =
IF Len(ToText(Previous Date)) <> 0 THEN DateDiff('d', (Previous Date, (table.statusdate))

Hope this helps.

FireGeek21

FireGeek
(currently using Crystal Reports XI with Lawson 8.03)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top