Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Duration formula without working hours?

Status
Not open for further replies.

ronin316

Technical User
Aug 11, 2005
2
CA
Any help would be appreciated

I have the following formula:

( if( [start_time] = null, [duration] , if( [end_time] = null , [duration] , if( [end_time] > [start_time] , ([end_time] - [start_time] + 30 ) /60 , if( [start_time] > [end_time] , ( ( (Time( 23 , 59 , 59) - [Start_time] ) + 31) / 60 + (Hour( [end_time]) X 60 ) + Minute( [End_time] , 0 ) ) ) ) ) + ( ( ( [end_date] - [start_date] ) X 24 ) X 60 )

This determines the number of minutes between the fields. I now need to minus the non-working minutes that may fall in the range. This is a form formula and I am not able to create queries inside this application. The working hours are 9-5 Monday to Friday.

Any help would be appreciated, I am having a brain burp

Thanks
 
You can't ever use "[any expression] = Null" since Null is unknown and you can't compare unknown to anything. ALso, there is no If() in Access.

You can possibly use something like [blue]IIf(IsNull([duration]),[duration],...)[/blue].

Since you seem to have a fairly complex expression that depends on 5 values, I would create a user-defined-function to perform the logic and calculation. This would be much easier to write and maintain than a huge, complex expression.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top