Hello there,

I have a db where I have the following fields:

log_date log_hour number

10/15/13 24:00 12345

10/16/13 01:00 12356

There are 24 hours for each day so I have 24 records for each day starting with 01:00 and ending with 24:00. I am trying to use the number from let's say hour 01:00 and subtract from the number in hour 02:00. My calculation works by subracting the number field between log_hour "02:00" and log hour "01:00". I used relationships to provide the basis for the calculations for the hours during the same day but to get the last hour from the previous day seems to be beyond my brain power at the moment. This works fine until I try to subtract the 01:00 hour from the 24:00 hour from the previous day. I know I am missing something simple but for the life of me I can't figure that one out.

Any suggestions?

Thanks,

Wayne

You only need one self-join relationship, using a timestamp calculation from the date and time field. Sort it descending, and the first record via this relationship is the respective previous entry, even across the day boundary.