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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Calculate Working Days

Status
Not open for further replies.

zaq888

MIS
Jun 2, 2003
46
0
0
MY
Hi guys....

i have problem on How To Calculate Working Days excluding sunday. Here in my place, Sunday is Weekdays(holiday).
My Q is how can i calculate wether abc(user) not login to the system during the 3 consecutive days?

e.g if abc did not log on 20 june 2003,(friday), then he not log in again in 21 June(saturday), 22 june is sunday, consider not working days. in 23 june (monday) abc still not login.. how can i print the not login user for last 3 consecutive days?

Can anyone help me....

I'm Keep Studying.... please show the way...
Not Good in English
 
faq181-261


at least for the working days between two dates part.



MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
is there any other ways to do it according to the problem?

I'm Keep Studying.... please show the way...
Not Good in English
 
This how I determine Posting Dates in VB.Net.

Your dates may vary by Country and State
Public Class PostingDates
' Monday is a Holiday if a Holiday date occurs on Sunday
' Holiday-Date()=01 ' New Year's - day = 01
' Holiday-Date()=01 ' New Year's - day = 02 and Monday
' Holiday-Date()=01 ' MLK 3rd Monday - day >= 15 And day <= 21 and Mon
' Holiday-Date()=02 ' Presidents' Day 3rd Monday - day >= 15 And day <= 21 and mon
' Holiday-Date()=05 ' Memorial Day Last Monday - day >= 25 and Mon
' Holiday-Date()=07 ' Independence Day - day = 4
' Holiday-Date()=07 ' Independence Day - day = 5 and Mon
' Holiday-Date()=09 ' Labor Day 1st Monday - day <= 7 and Mon
' Holiday-Date()=10 ' Columbus Day 2nd Monday = day >= 8 And day <= 14 and Mon
' Holiday-Date()=11 ' Veteran's Day - day = 11
' Holiday-Date()=11 ' Veteran's Day - day = 12 and Mon
' Holiday-Date()=11 ' Thanksgiving Day 4th - Day >= 22 And Day <= 28 and Mon
' Holiday-Date()=12 ' Christmas - day = 25
' Holiday-Date()=12 ' Christmas - day = 26 and Mon
Public Shared Function _
GetLastPostingDate( _
ByVal Fromdate As Date) _
As Date

Do
Fromdate = Fromdate.AddDays(-1)
Loop While Not IsPostingDate(Fromdate)
Return Fromdate
End Function

Public Shared Function _
GetNextPostingDate( _
ByVal FromDate As Date) _
As Date

Do
FromDate = FromDate.AddDays(+1)
Loop While Not IsPostingDate(FromDate)
Return FromDate
End Function

Public Shared Function _
IsPostingDate( _
ByVal TestDate As Date) _
As Boolean

Select Case TestDate.DayOfWeek()
Case DayOfWeek.Saturday, DayOfWeek.Sunday
Return False
Case Else
Return Not IsWeekdayHoliday(TestDate)
End Select
End Function

Public Shared Function _
IsWeekdayHoliday( _
ByVal TestDate As Date) _
As Boolean
Dim nDay, nMonth As Integer

nMonth = TestDate.Month
nDay = TestDate.Day
Select Case nMonth
Case 1
' January
' New Year's Day
' MLK 3rd Monday
If nDay = 1 Then
Return True
ElseIf nDay = 2 AndAlso TestDate.DayOfWeek = DayOfWeek.Monday Then
Return True
ElseIf nDay >= 15 AndAlso nDay <= 21 AndAlso _
TestDate.DayOfWeek = DayOfWeek.Monday Then
Return True
Else
Return False
End If
Case 2
' February
' President's Day 3rd Monday
If nDay >= 15 AndAlso nDay <= 21 AndAlso _
TestDate.DayOfWeek = DayOfWeek.Monday Then
Return True
Else
Return False
End If
Case 5
' May
'' Memorial Day Last Monday
If nDay >= 25 AndAlso _
TestDate.DayOfWeek = DayOfWeek.Monday Then
Return True
Else
Return False
End If
Case 7
' July
' Independence Day
If nDay = 4 Then
Return True
ElseIf nDay = 5 AndAlso TestDate.DayOfWeek = DayOfWeek.Monday Then
Return True
Else
Return False
End If
Case 9
' September
' Labor Day 1st Monday
If nDay <= 7 AndAlso _
TestDate.DayOfWeek = DayOfWeek.Monday Then
Return True
Else
Return False
End If
Case 10
' October
' Columbus Day 2nd Monday
If nDay >= 8 AndAlso nDay <= 14 AndAlso _
TestDate.DayOfWeek = DayOfWeek.Monday Then
Return True
Else
Return False
End If
Case 11
' November
'Veteran's Day Nov 11
' Thanksgiving Day 4th Thursday
If nDay = 11 Then
Return True
ElseIf nDay = 12 AndAlso TestDate.DayOfWeek = DayOfWeek.Monday Then
Return True
ElseIf nDay >= 22 AndAlso nDay <= 28 AndAlso _
TestDate.DayOfWeek = DayOfWeek.Thursday Then
Return True
Else
Return False
End If
Case 12
' December
' Christmas Day
If nDay = 25 Then
Return True
ElseIf nDay = 26 AndAlso TestDate.DayOfWeek = DayOfWeek.Monday Then
Return True
Else
Return False
End If
End Select

End Function
End Class

Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
surely

day1=Weekday(date1,1) ' earliest
day2=Weekday(date2,1)
if day1-day2 > 0 then day2=day2+7

if ABS(day2-day1)<4 then result=&quot;you have it&quot;

would be a start

I have 2 minutes so I didn't check to see if it is in the post above.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top