Subtracting Dates

J

Jay Yate

I have a report that needs to subtract dates in the same
column different row e.g. date from row 1 subtracted from
date on row 2 etc.

The query orders by date DESC so all dates are less than
the prior date.

Subtracting 2 dates in 2 different columns of the same row
is easy. I'm not sure how to approach this.

Thanks.
 
M

Marshall Barton

Jay said:
I have a report that needs to subtract dates in the same
column different row e.g. date from row 1 subtracted from
date on row 2 etc.

The query orders by date DESC so all dates are less than
the prior date.


Use a calculated field in the report's record source query.
the general idea is to use a subquery something like this:

SELECT thetable.somefields, thetable.datefield,
(SELECT Max(X.datefield)
FROM thetable AS X
WHERE X.datefield < thetable.datefield
) AS PrevDate
FROM thetable
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top