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

Business Hours - can't quite get it to work

Business Hours - can't quite get it to work

(OP)
thread705-1207464: Calculate business hours between two times

The referenced thread is exactly what I was looking for (calculating business hours between two dates). When I run my query, the calculated hours appear, then I start getting error messages and the values disappear and are replaced with #Error.

When I debug, this is what gets highlighted:

'Initalize Start and End Date Times
MyDates(1).MyHrs = DateDiff("n", TimeValue(StDt), EndTim)
MyDates(UBound(MyDates)).MyHrs = DateDiff("n", StrtTim, TimeValue(EndDt))

I've tried replacing the DateDiff formula with a straight number (e.g. MyDates(1).MyHrs = 8). That line still gets highlighted. MyDates(1).MyHrs seems to be the source of the error.

Any ideas on what I've done wrong?

Thanks.

RE: Business Hours - can't quite get it to work

(OP)
Thanks for the reply.

Hmm. Checking...

No nulls. All contain a date and time value. (e.g., 7/15/2014 2:46:23 PM)

RE: Business Hours - can't quite get it to work

I would filter the records by half and try run your query. Continue doing this to find if it's just a number of records that cause the issue. Once you find the records you should be able to find the problem and resolve it.

Duane
Hook'D on Access
MS Access MVP

RE: Business Hours - can't quite get it to work

(OP)
Ah, very clever.

It seems I had an extra line of code in there to push to the morning of the next business day those start times that were after business hours. So only the time stamps after 5pm were causing the error.

Many thanks! 2thumbsup

Now I just have to figure how out to mark this thread as solved...

RE: Business Hours - can't quite get it to work

If you want "to mark this thread as solved", award a star to Duane by clicking on "Great Post" on his reply.

And welcome to Tek-Tips wavey3

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.

RE: Business Hours - can't quite get it to work

Yes, welcome to Tek-tips and thanks for the star.

One of my strategies for resolving any issue is to chop things into smaller pieces whether it's code or records. Sometimes I start from the smallest set and begin adding and other times it's divide in halves and repeat.

Duane
Hook'D on Access
MS Access MVP

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