473,382 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Computing the past monday - Friday when Sunday occurs

Hello Everyone,

Can you tell me how to produce a query that when Login Date (entry) is
Sunday. First, check if the Sunday Date occur on 7th day of his duty.

Example 1:

Login Date no. of wk days Remark

11/01/04 1
11/02/04 2
11/07/04 (Sunday) 3 - Regular Working Day
Example 2:

Login Date no. of wk days

11/01/04 1
11/02/04 2
11/03/04 3
11/04/04 4
11/07/04 (Sunday) 5 - Regular Working Day
11/08/04 1
11/09/04 2
11/10/04 3
11/11/04 4
11/12/04 5
11/13/04 6
11/14/04 (Sunday) 7 - Sunday Working Day

Take note of the Remark

This is the kind of query I am trying to produce for 2 months now.
But still I can't figure out what to do. Need Assistance ASAP
I want in this case if 11/07/04. Weekday is Sunday, right. If weekday
of login date is Sunday. Check the previous login date b4 11/07/04 if
no. of days from 11/01/04 to 11/07/04 is 7 days then 11/07/04 is
Sunday, if not equal to 7 working days then 11/07/04 is a regular
working day instead of Sunday Working day.

in this example: You can see that 11/07/04 login date falls on 3rd
working days. Therefore, 11/07/04 is not Sunday but as regular day.
I am refering to Working Day Status not the day of date.

Working Day Status is compose of three type:

Sunday Working Day - If the employee login date is Sunday and the
previous login date is not less than 6 days
before 11/07/04 for example.

Regular Working Day - If the employee login date is from Monday to
Saturday.

Holiday - If the employee login date is declared as
Holiday like: 12/25/04 - Christmas Eve.

How will I do this ? I need detailed solution. the 7 days computation
will occur everytime the login date's weekday is vbSunday.

So, It is a continous entry regardless of month and weeks. As long as
the 7th day is Sunday, consider it as Sunday Working Day. Otherwise, if
Sunday falls less than 7 days then it is considered as Regulard Working
Day instead of Sunday Working Day.

I hope you got the point. I tried this several times but no one can
give me the exact solution. All the solution given to me is good only
for 1st week but when 2nd week or shall I say 2nd Sunday occurs, the
result is not the way it should be. Maybe the solution did not compute
7 days again for the succeeding weeks.

As long as Sunday Occurs in login date, I want a solution that it
computes where the login date falls. See above illustration and read
carefully to follow what I'm trying to accomplish in this application.
Thanks

Tim

Nov 13 '05 #1
1 1723
rock72 wrote:
Hello Everyone,

Can you tell me how to produce a query that when Login Date (entry) is
Sunday. First, check if the Sunday Date occur on 7th day of his duty.

Example 1:

Login Date no. of wk days Remark

11/01/04 1
11/02/04 2
11/07/04 (Sunday) 3 - Regular Working Day
Example 2:

Login Date no. of wk days

11/01/04 1
11/02/04 2
11/03/04 3
11/04/04 4
11/07/04 (Sunday) 5 - Regular Working Day
11/08/04 1
11/09/04 2
11/10/04 3
11/11/04 4
11/12/04 5
11/13/04 6
11/14/04 (Sunday) 7 - Sunday Working Day

Take note of the Remark

This is the kind of query I am trying to produce for 2 months now.
But still I can't figure out what to do. Need Assistance ASAP
I want in this case if 11/07/04. Weekday is Sunday, right. If weekday
of login date is Sunday. Check the previous login date b4 11/07/04 if
no. of days from 11/01/04 to 11/07/04 is 7 days then 11/07/04 is
Sunday, if not equal to 7 working days then 11/07/04 is a regular
working day instead of Sunday Working day.

in this example: You can see that 11/07/04 login date falls on 3rd
working days. Therefore, 11/07/04 is not Sunday but as regular day.
I am refering to Working Day Status not the day of date.

Working Day Status is compose of three type:

Sunday Working Day - If the employee login date is Sunday and the
previous login date is not less than 6 days
before 11/07/04 for example.

Regular Working Day - If the employee login date is from Monday to
Saturday.

Holiday - If the employee login date is declared as
Holiday like: 12/25/04 - Christmas Eve.

How will I do this ? I need detailed solution. the 7 days computation
will occur everytime the login date's weekday is vbSunday.

So, It is a continous entry regardless of month and weeks. As long as
the 7th day is Sunday, consider it as Sunday Working Day. Otherwise, if
Sunday falls less than 7 days then it is considered as Regulard Working
Day instead of Sunday Working Day.

I hope you got the point. I tried this several times but no one can
give me the exact solution. All the solution given to me is good only
for 1st week but when 2nd week or shall I say 2nd Sunday occurs, the
result is not the way it should be. Maybe the solution did not compute
7 days again for the succeeding weeks.

As long as Sunday Occurs in login date, I want a solution that it
computes where the login date falls. See above illustration and read
carefully to follow what I'm trying to accomplish in this application.
Thanks

Tim


Tim:

I tested a solution. I set up a tblLogin containing as UserID (integer),
LoginDate (Date), and Worktype ("G", "S" or "H" for type of workday. I I
add records for User #1 for the dates 11/8/04 through 11/13/04.

I created the following query:

PARAMETERS UserID Short, TimeClock DateTime;
INSERT INTO tblLogin ( UserID, LoginDate, WorkType )
SELECT [UserID] AS [User], [TimeClock] AS LD,
GetWorkType([UserID],[TimeClock]) AS WT;

The query calls this routine:

'(START OF CODE)

Public Function GetWorkType(intUserID As Integer, dteLoginDate As Date)
As String
Dim varDayOfWeek As Variant
Dim intDaysWorked As Integer
Dim strCriteria As String

varDayOfWeek = Weekday(dteLoginDate)
If varDayOfWeek <> vbSunday Then
GetWorkType = "R"
Else
strCriteria = "[UserID] = " & intUserID & " AND ("
strCriteria = strCriteria & "[LoginDate] >= #" & DateAdd("d",
-6, dteLoginDate) & "#"
strCriteria = strCriteria & " AND [LoginDate] < #" &
dteLoginDate & "#)"
intDaysWorked = DCount("UserID", "tblLogin", strCriteria)
If intDaysWorked < 6 Then
GetWorkType = "R"
Else
GetWorkType = "S"
End If
End If

End Function

'(END OF CODE)

I then ran the query, entering 1 for the UserID parameter and 11/14/04
for the LoginDate. It returned "S" as the WorkType, which was correct.

You will have to modify this for your own application, of course, but I
hope this gives you an approach to solving the problem.
Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Martien van Wanrooij | last post by:
I would like to retrieve, let us say, the First Monday after a certain date, so my (imaginary) function could be something like echo weekdayAfter("28 July 2005", "Monday") should return "1 August...
5
by: Drum2001 | last post by:
Currently I am running the following query: SELECT DateFilter.Employee, DateFilter.TimeTypeIn, sectodur(IIf(Sum(DateDiff("s",,))-40*60*60>0,Sum(DateDiff("s",,))-40*60*60,0)) AS Overtime,...
7
by: bojan.pikl | last post by:
Hi, I am making a calendar. It is costum made and I would like to have the ability to choose the first day (Monday or Sunday). I know for the firstDayOfWeek, but I can't change it. What should I...
5
by: Chris | last post by:
I am trying to output Monday of the current week i.e. if Monday is the 8th I want to display 'Monday 8th' for any date between Monday 8-14th. I would appreciate any help, the code below is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.