Solved

Looping for a particular datetime

Posted on 2008-10-22
6
353 Views
Last Modified: 2013-11-15
I have a databases which stores dates for a particular process.  The process can have many different elements i.e can be changed from one stage to another, pending, here, their, anywhere...

example

Process 123456
                                MODDATE                                                STAGEDATE
                          1      13/10/2008  10:06:31                             13/10/2008  10:06:31
                          2      13/10/2008  10:06:31                             13/10/2008  10:06:31
                          3      13/10/2008  10:09:45                             13/10/2008  10:06:31
                          4      13/10/2008  10:46:08                             13/10/2008  10:49:31
                          5      13/10/2008  10:51:19                             13/10/2008  10:51:20

Here the stage date is what is of interest.  I need to use crystal, a formula Im assuming to get the STAGEDATE which signifies a change.  In this case it would be RowNum 4 albeit 5 is different Im only interested in 4.  How can I use Crystal to look through each record to do it .  Bear in mind their are 1000s of different processes.  A typical process could be - PAYJOEBLOGGS which has several elements in its actual completion such as start, pending, waiting, departmentx etc.  The table is called PROCESS and each unique processID has lots of different elements as I have depicted above, 1,2,3,4 & 5 all belong to process 123456.  Im messing abotu with WHILEREADINGRECORD etc but I think a loop is needed.

Thanks


0
Comment
Question by:BPMonk
  • 2
  • 2
6 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 22777494
You cannot truly loop through the records in Crystal.

Crystal works on 1 record at a time and handles the "looping" for you.

You can group on the process id
In the detail sectiion you can add a formula that compares the ModDate and Stage date  like

If {ModDateField} <> {StageDateField} then
    Do something

mlmcc
0
 

Author Comment

by:BPMonk
ID: 22783650
Trouble is mlmcc is that I need to get only the one record where their was a change, in thsi case

4      13/10/2008  10:46:08                             13/10/2008  10:49:31

I then need to compare this to the start time 13/10/2008  10:06:31    and acquire the difference.
0
 

Author Comment

by:BPMonk
ID: 22783693
What I could do is set a flag where their is a change i.e

                          1      13/10/2008  10:06:31                             13/10/2008  10:06:31                      0
                          2      13/10/2008  10:06:31                             13/10/2008  10:06:31                      0
                          3      13/10/2008  10:09:45                             13/10/2008  10:06:31                      0
                          4      13/10/2008  10:46:08                             13/10/2008  10:49:31                      1
                          5      13/10/2008  10:51:19                             13/10/2008  10:51:20                      2

This sets the first change as 1 and the second as 2.  I can then get rid of antything that isnt 1 then write a formula to calculate the variance...
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 250 total points
ID: 22786475
I assume you have a group on the process id
In the group header add a formula
WhilePrintingRecords;
Global DateTimeVar ProcessStartTime;
ProcessStartTime := {ModDate};
''

In the formula I provided

WhilePrintingRecords;
Global DateTimeVar ProcessStartTime;
If {ModDateField} <> {StageDateField} then
    DateDiff('s',   ProcessStartTime, {StageDateField})

If you want to display it as something other than seconds then you need to add code to convert the seconds to the format you want.

mlmcc
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question