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

date math, omiting weekends and holidays,

P: 98
This code omits weekends, holidays and returns a due date as well as the number of business days due. it also adds an extra day to the reqest if it was submitted after 5:00.

as you can see that if the request is submitted between 12-pm and 12:59 pm, it is going to add an extra day to the count. how might add the condition that if 12 and pm, no extra days needed?

Expand|Select|Wrap|Line Numbers
  1.  'if submitted after 4:59 PM then add a day if after 4:59 PM and a Friday add 2 days others wise add no extra days
  2.     loopend = Val(Me.Days) 'default # of days
  3.     DueDate = Me.Date_Submitted
  4.     If Right(Me.Date_Submitted, 2) = "PM" Then
  5.         colonPos = InStr(Me.Date_Submitted, ":")
  6.        ' If (Val(Mid(Me.Date_Submitted, colonPos - 2, 2)) > 4) And (Trim(Format(Date, "dddd")) = "Friday") Then 'get the day of the week
  7.           '  loopend = loopend + 1
  8.         If Val(Mid(Me.Date_Submitted, colonPos - 2, 2)) > 4 Then
  9.             loopend = loopend + 1
  10.  
  11.         End If
  12.     End If
Nov 13 '08 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 374
This code omits weekends, holidays and returns a due date as well as the number of business days due. it also adds an extra day to the reqest if it was submitted after 5:00.

as you can see that if the request is submitted between 12-pm and 12:59 pm, it is going to add an extra day to the count. how might add the condition that if 12 and pm, no extra days needed?

Expand|Select|Wrap|Line Numbers
  1.  'if submitted after 4:59 PM then add a day if after 4:59 PM and a Friday add 2 days others wise add no extra days
  2.     loopend = Val(Me.Days) 'default # of days
  3.     DueDate = Me.Date_Submitted
  4.     If Right(Me.Date_Submitted, 2) = "PM" Then
  5.         colonPos = InStr(Me.Date_Submitted, ":")
  6.        ' If (Val(Mid(Me.Date_Submitted, colonPos - 2, 2)) > 4) And (Trim(Format(Date, "dddd")) = "Friday") Then 'get the day of the week
  7.           '  loopend = loopend + 1
  8.         If Val(Mid(Me.Date_Submitted, colonPos - 2, 2)) > 4 Then
  9.             loopend = loopend + 1
  10.  
  11.         End If
  12.     End If

Expand|Select|Wrap|Line Numbers
  1.  'if submitted after 4:59 PM then add a day if after 4:59 PM and a Friday add 2 days others wise add no extra days
  2.     loopend = Val(Me.Days) 'default # of days
  3.     DueDate = Me.Date_Submitted
  4.     If Right(Me.Date_Submitted, 2) = "PM" Then
  5.         colonPos = InStr(Me.Date_Submitted, ":")
  6.        ' If (Val(Mid(Me.Date_Submitted, colonPos - 2, 2)) > 4) And (Trim(Format(Date, "dddd")) = "Friday") Then 'get the day of the week
  7.           '  loopend = loopend + 1
  8.        'If Val(Mid(Me.Date_Submitted, colonPos - 2, 2)) > 4 Then
  9.        '     loopend = loopend + 1
  10.  
  11.         'End If
  12.         If TimeSerial(Hour(me.Date_Submitted),Minute(me.Date_Submitted),Second(me.Date_Submitted)) > #4:59PM# Then
  13.               loopend = loopend + 1
  14.         end if
  15.     End If
  16.  
  17.  
Nov 17 '08 #2

Post your reply

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