By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,663 Members | 1,792 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,663 IT Pros & Developers. It's quick & easy.

Sum of DateDiff in a report

P: 41
As the title says, I'm trying to find the sum of a field I created in a report, which is for the difference in 2 times (in seconds). Here's what I'm trying:

=Sum(DateDiff("s",[ReviewStartTime],[ReviewStartTime]))

and it comes up as 0.

Is it because the field was created in the report and it's not an actual field on the table?

Is it possible to put a DateDiff as an actual field on the table and would that simplify things?

Thanks!

Jesse
Jul 15 '09 #1
Share this Question
Share on Google+
8 Replies


Expert 100+
P: 1,287
You should create a query based on the table and add a field where you put the formula. The query builder will put Expr1: in front of the formula, and you should change the name of the field to something sensible. Then just base the report on the query.
Jul 15 '09 #2

P: 41
Oh wow, you're the best.

Now that makes me formatting the time more difficult. I have it in seconds in the query, and in the report, I want to convert it to say something like "1hr 12min 4sec". I know I could do this within the query, but I'd like to keep it in seconds there, so I can sum and average times within the report.

I think this makes sense. Any ideas?
Jul 15 '09 #3

Expert 100+
P: 1,287
The Format function can sort-of do this.
Format (seconds / 86400, "hh:nn:ss")
Jul 15 '09 #4

missinglinq
Expert 2.5K+
P: 3,532
Oh, come on people! Would you really expect

=Sum(DateDiff("s",[ReviewStartTime],[ReviewStartTime]))

to return anything but zero? Both arguments are the same field!

Welcome to Bytes!

Linq ;0)>
Jul 15 '09 #5

Expert 100+
P: 1,287
Hah, good one spotting that Linq :)
I was thinking of trying to get the Sum of a calcuated field in a report, but that would be a blank rather than zero wouldn't it? At least the effort of making the query isn't wasted.
Jul 15 '09 #6

P: 41
Doh! Good catch, but that wasn't the problem, anyways, because I had tried it a few times in a few places a few different ways, and I know it was written correctly just about every time except the time I made the post :(

But yes, the query worked great!

Guh, I'm so clueless when it comes to access, but I'm learning. I'll do a little more research on the couple other questions I have and see if I can figure them out myself.

Thanks again!
Jul 16 '09 #7

P: 41
Everything figured out, thanks for the help!
Jul 16 '09 #8

missinglinq
Expert 2.5K+
P: 3,532
Glad we could help!

Linq ;0)>
Jul 16 '09 #9

Post your reply

Sign in to post your reply or Sign up for a free account.