INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Subtract previous minimum time from current minimum time

Subtract previous minimum time from current minimum time

(OP)
I'm using the formula below to calculate "actHdwy". However the formula places the "actHdwy" next to wrong vehicle.
For example, vehicle 5005 does not have "actHdwy" of 11 minutes, bus 5007 should be 11 minutes.
Vehicle 5017 should be 19 minutes, vehicle 5008 should be 11 minutes, 5013 should 16 minutes, etc.,

In other words, how can I modify the formula below to shift the "actHdwy" down to the correct vehicle?
Thanks for any assistance.

WhilePrintingRecords; //Place in Group Footer
if {command.vehicle_id} <> Next({command.vehicle_id}) then
(
Time(next({command.incident_date_time})) -
Time(Minimum ({command.incident_date_time}, {command.vehicle_id}))
)/60
else 0;

incDate sched_time actHdwy vehicle_id
5:10:54 AM 5:07 AM 0 5005
5:13:54 AM 5:07 AM 0 5005
5:15:54 AM 5:07 AM 11 5005

5:21:54 AM 5:22 AM 19 5007

5:40:54 AM 5:37 AM 11 5017

5:51:56 AM 5:52 AM 16 5008

6:07:55 AM 6:07 AM 18 5013

6:25:56 AM 6:22 AM 5 5020

6:30:55 AM 6:34 AM 0 5021
6:40:55 AM 6:34 AM 17 5021

6:47:55 AM 6:49 AM 16 5011

7:03:55 AM 7:04 AM 13 5015

7:16:56 AM 7:16 AM 12 5002

7:28:56 AM 7:28 AM 0 5006
7:30:56 AM 7:28 AM 13 5006

7:41:56 AM 7:40 AM 9 5019

7:50:56 AM 7:52 AM 12 5066

8:02:56 AM 8:04 AM 0 5014
8:04:56 AM 8:04 AM 0 5014
8:06:56 AM 8:04 AM 11 5014

8:13:56 AM 8:16 AM 12 5022

8:25:56 AM 8:28 AM 0 5012
8:26:56 AM 8:28 AM 0 5012
8:27:56 AM 8:28 AM 0 5012
8:31:56 AM 8:28 AM 21 5012

8:46:57 AM 8:42 AM 9 5005

RE: Subtract previous minimum time from current minimum time

If you want it on the next line, change your logic from using Next to using Previous.

RE: Subtract previous minimum time from current minimum time

(OP)
I'm trying to subtract previous minimum time from current minimum time, but I get an error.
Can someone explain?

WhilePrintingRecords; //Place in Group Footer
if {command.vehicle_id} <> previous({command.vehicle_id}) then
(
Time(Minimum ({command.incident_date_time}, {command.vehicle_id})) -
Time(previous(Minimum ({command.incident_date_time}, {command.vehicle_id})))
)/60
else 0;

RE: Subtract previous minimum time from current minimum time

What error do you get?

RE: Subtract previous minimum time from current minimum time

(OP)
The Error is "This field has no previous value"

(previous(Minimum ({command.incident_date_time}, {command.vehicle_id})))

Is it possible to get the previous minimum incident_date_time?

Or is there another way to subtract previous minimum time from current minimum time?

RE: Subtract previous minimum time from current minimum time

Add this to the beginning of your formula: Not(onfirstrecord) and .... the rest of your formula.....

RE: Subtract previous minimum time from current minimum time

(OP)
Just noticed your response Charliy. Thanks.

I think it's going to work the way it is currently set up.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close