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 Days

# Business Days

(OP)
I have 2 fields that I need to use to calculate a Service Date.

The first field is "Created_Date" and the second is "Service_Level_days.

The Service level days is the number of business days a item needs to be "closed" in. I need to create a field that shows the following:

if the Created_date = 1/3/2017 and the Service_Level_days = 2 i need the Service_date to = 1/31/2017

Is there a way to accomplish this in a querey?

Thanks for any help or suggestions.

Paul

RE: # Business Days

Hi,

Every company I have worked for, has a Business Calendar table, containing workdays, holidays, accounting weeks/months etc.

Join your table(s) to your Business Calendar using the appropriate criteria for your requirements.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: # Business Days

(OP)
Thank you Skip, I will look into that.

RE: # Business Days

Build yourself a table of non work days for your business. Do not include weekends. Make it for many years out. Apply your business rules.

CODE -->

tblHolidays
ID	dtmDate	        Type
1       1/1/2017        New Years
2       1/16/2017       MLK
3       1/20/2017       Innauguration
....
n       12/25/2030      XMas 


Build a UDF and helper UDFs

CODE

Public Function GetServiceDate(CreatedDate As Variant, LevelDays As Variant) As Date
  Dim i As Integer
  Dim Bizdays As Integer
  
  If IsDate(CreatedDate) And Not IsNull(LevelDays) Then
    GetServiceDate = CreatedDate
    Do
      GetServiceDate = GetServiceDate + 1
      If Not IsHoliday(GetServiceDate) And Not IsWeekend(GetServiceDate) Then Bizdays = Bizdays + 1
    Loop Until Bizdays = LevelDays
  End If
End Function

Public Function IsHoliday(dtmDate As Date) As Boolean
  IsHoliday = (DCount("*", "tblHolidays", "dtmDate = #" & dtmDate & "#") > 0)
End Function

Public Function IsWeekend(dtmDate As Date) As Boolean
  IsWeekend = (Weekday(dtmDate) = vbSunday Or Weekday(dtmDate) = vbSaturday)
End Function 

in a query

CODE -->

Select ...., GetServiceDate([Created_Date],[Service_Level_days]) AS Service_Date from sometable .... 

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