473,486 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Monday --> Sunday

Currently I am running the following query:

SELECT DateFilter.Employee, DateFilter.TimeTypeIn,
sectodur(IIf(Sum(DateDiff("s",[clockin],[clockout]))-40*60*60>0,Sum(DateDiff("s",[clockin],[clockout]))-40*60*60,0))
AS Overtime, DateAdd("d",-Weekday([ClockInDate]),[ClockInDate])+1 AS
WeekOf
FROM DateFilter
GROUP BY DateFilter.Employee, DateFilter.TimeTypeIn,
DateAdd("d",-Weekday([ClockInDate]),[ClockInDate])+1
HAVING (((DateFilter.TimeTypeIn)="Regular"));
This is designed to calculate overtime. If someone's hours are over
40, it will calculate the number of hours over 40.

Currently it calculates the week from Sunday though Saturday. Is there
anyway to have it calculate from Monday through Sunday?

I know the "-Weekday()" command by default begins Monday. Is there a
way to modify this or is there another 'function' that begins on
Sunday?

Any help would be great!

Thank you!

Jul 11 '06 #1
5 2358
Here is an example of a similar problem I solved some time ago. In my
example, the week started on Monday:

SELECT tblEmployee.EmpID, [EmpFirstName] & " " & [EmpLastName] AS EmpName,
tblTimeEntry.EmpJobSite, tblJobSite.JobSite, tblJobSite.JobAddress,
tblJobSite.JobCity, tblJobSite.JobState, tblJobSite.JobZip,
tblJobSite.JobStartDate, tblJobSite.JobEndDate, tblJobSite.JobSiteName,
tblJobSite.JobSiteClientCode, Format([InTimeStamp],"ww",2) AS weekNum
FROM tblJobSite INNER JOIN (tblEmployee INNER JOIN tblTimeEntry ON
tblEmployee.EmpID = tblTimeEntry.EmpID) ON tblJobSite.JobID =
tblTimeEntry.EmpJobSite
GROUP BY tblEmployee.EmpID, [EmpFirstName] & " " & [EmpLastName],
tblTimeEntry.EmpJobSite, tblJobSite.JobSite, tblJobSite.JobAddress,
tblJobSite.JobCity, tblJobSite.JobState, tblJobSite.JobZip,
tblJobSite.JobStartDate, tblJobSite.JobEndDate, tblJobSite.JobSiteName,
tblJobSite.JobSiteClientCode, Format([InTimeStamp],"ww",2)
HAVING (((Format([InTimeStamp],"ww",2)) Between
Format([Forms]![frmReports]![txtStartDate],"ww",2) And
Format([Forms]![frmReports]![txtEndDate],"ww",2)));
The part of the query above which makes the week start on Monday is

Format([InTimeStamp],"ww",2) AS weekNum
Linda

"Drum2001" <dr******@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
Currently I am running the following query:

SELECT DateFilter.Employee, DateFilter.TimeTypeIn,
sectodur(IIf(Sum(DateDiff("s",[clockin],[clockout]))-40*60*60>0,Sum(DateDiff("s",[clockin],[clockout]))-40*60*60,0))
AS Overtime, DateAdd("d",-Weekday([ClockInDate]),[ClockInDate])+1 AS
WeekOf
FROM DateFilter
GROUP BY DateFilter.Employee, DateFilter.TimeTypeIn,
DateAdd("d",-Weekday([ClockInDate]),[ClockInDate])+1
HAVING (((DateFilter.TimeTypeIn)="Regular"));
This is designed to calculate overtime. If someone's hours are over
40, it will calculate the number of hours over 40.

Currently it calculates the week from Sunday though Saturday. Is there
anyway to have it calculate from Monday through Sunday?

I know the "-Weekday()" command by default begins Monday. Is there a
way to modify this or is there another 'function' that begins on
Sunday?

Any help would be great!

Thank you!

Jul 11 '06 #2
Thank you for your response!

How would I put this into my code? I dont understand the logic of the
function.


Linda Burnside wrote:
Here is an example of a similar problem I solved some time ago. In my
example, the week started on Monday:

SELECT tblEmployee.EmpID, [EmpFirstName] & " " & [EmpLastName] AS EmpName,
tblTimeEntry.EmpJobSite, tblJobSite.JobSite, tblJobSite.JobAddress,
tblJobSite.JobCity, tblJobSite.JobState, tblJobSite.JobZip,
tblJobSite.JobStartDate, tblJobSite.JobEndDate, tblJobSite.JobSiteName,
tblJobSite.JobSiteClientCode, Format([InTimeStamp],"ww",2) AS weekNum
FROM tblJobSite INNER JOIN (tblEmployee INNER JOIN tblTimeEntry ON
tblEmployee.EmpID = tblTimeEntry.EmpID) ON tblJobSite.JobID =
tblTimeEntry.EmpJobSite
GROUP BY tblEmployee.EmpID, [EmpFirstName] & " " & [EmpLastName],
tblTimeEntry.EmpJobSite, tblJobSite.JobSite, tblJobSite.JobAddress,
tblJobSite.JobCity, tblJobSite.JobState, tblJobSite.JobZip,
tblJobSite.JobStartDate, tblJobSite.JobEndDate, tblJobSite.JobSiteName,
tblJobSite.JobSiteClientCode, Format([InTimeStamp],"ww",2)
HAVING (((Format([InTimeStamp],"ww",2)) Between
Format([Forms]![frmReports]![txtStartDate],"ww",2) And
Format([Forms]![frmReports]![txtEndDate],"ww",2)));
The part of the query above which makes the week start on Monday is

Format([InTimeStamp],"ww",2) AS weekNum
Linda

"Drum2001" <dr******@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
Currently I am running the following query:

SELECT DateFilter.Employee, DateFilter.TimeTypeIn,
sectodur(IIf(Sum(DateDiff("s",[clockin],[clockout]))-40*60*60>0,Sum(DateDiff("s",[clockin],[clockout]))-40*60*60,0))
AS Overtime, DateAdd("d",-Weekday([ClockInDate]),[ClockInDate])+1 AS
WeekOf
FROM DateFilter
GROUP BY DateFilter.Employee, DateFilter.TimeTypeIn,
DateAdd("d",-Weekday([ClockInDate]),[ClockInDate])+1
HAVING (((DateFilter.TimeTypeIn)="Regular"));
This is designed to calculate overtime. If someone's hours are over
40, it will calculate the number of hours over 40.

Currently it calculates the week from Sunday though Saturday. Is there
anyway to have it calculate from Monday through Sunday?

I know the "-Weekday()" command by default begins Monday. Is there a
way to modify this or is there another 'function' that begins on
Sunday?

Any help would be great!

Thank you!
Jul 11 '06 #3
Could someone explain in words what this is doing?

WeekOf: DateAdd("d",-Weekday([ClockInDate])+1,[ClockInDate])

ClockInDate is a Time/Date field for a Date stamp for when users "punch
in".

Drum2001 wrote:
Thank you for your response!

How would I put this into my code? I dont understand the logic of the
function.


Linda Burnside wrote:
Here is an example of a similar problem I solved some time ago. In my
example, the week started on Monday:

SELECT tblEmployee.EmpID, [EmpFirstName] & " " & [EmpLastName] AS EmpName,
tblTimeEntry.EmpJobSite, tblJobSite.JobSite, tblJobSite.JobAddress,
tblJobSite.JobCity, tblJobSite.JobState, tblJobSite.JobZip,
tblJobSite.JobStartDate, tblJobSite.JobEndDate, tblJobSite.JobSiteName,
tblJobSite.JobSiteClientCode, Format([InTimeStamp],"ww",2) AS weekNum
FROM tblJobSite INNER JOIN (tblEmployee INNER JOIN tblTimeEntry ON
tblEmployee.EmpID = tblTimeEntry.EmpID) ON tblJobSite.JobID =
tblTimeEntry.EmpJobSite
GROUP BY tblEmployee.EmpID, [EmpFirstName] & " " & [EmpLastName],
tblTimeEntry.EmpJobSite, tblJobSite.JobSite, tblJobSite.JobAddress,
tblJobSite.JobCity, tblJobSite.JobState, tblJobSite.JobZip,
tblJobSite.JobStartDate, tblJobSite.JobEndDate, tblJobSite.JobSiteName,
tblJobSite.JobSiteClientCode, Format([InTimeStamp],"ww",2)
HAVING (((Format([InTimeStamp],"ww",2)) Between
Format([Forms]![frmReports]![txtStartDate],"ww",2) And
Format([Forms]![frmReports]![txtEndDate],"ww",2)));
The part of the query above which makes the week start on Monday is

Format([InTimeStamp],"ww",2) AS weekNum
Linda

"Drum2001" <dr******@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
Currently I am running the following query:
>
SELECT DateFilter.Employee, DateFilter.TimeTypeIn,
sectodur(IIf(Sum(DateDiff("s",[clockin],[clockout]))-40*60*60>0,Sum(DateDiff("s",[clockin],[clockout]))-40*60*60,0))
AS Overtime, DateAdd("d",-Weekday([ClockInDate]),[ClockInDate])+1 AS
WeekOf
FROM DateFilter
GROUP BY DateFilter.Employee, DateFilter.TimeTypeIn,
DateAdd("d",-Weekday([ClockInDate]),[ClockInDate])+1
HAVING (((DateFilter.TimeTypeIn)="Regular"));
>
>
This is designed to calculate overtime. If someone's hours are over
40, it will calculate the number of hours over 40.
>
Currently it calculates the week from Sunday though Saturday. Is there
anyway to have it calculate from Monday through Sunday?
>
I know the "-Weekday()" command by default begins Monday. Is there a
way to modify this or is there another 'function' that begins on
Sunday?
>
Any help would be great!
>
Thank you!
>
Jul 11 '06 #4
WeekOf is the field being calculated

The Dateadd function says to add something to a date - The date being
added to is the field at the end ([ClockInDate])

The "d" says to add days to the date

The expression "-Weekday([ClockInDate])+1" is computing how many days
to add. (This number can be negative - in which case it is actually
subtracting days from the date)

Weekday([ClockInDate]) says give me the day of the week. (July 4
which is a Tuesday would give me a 3)

If the Clockindate is July 4, 2006
The "-Weekday([ClockInDate])+1" expressing is evaluated as
follows:

((-1) * 3) + 1
-3 + 1
-2

consequently

WeekOf: DateAdd("d",-Weekday([ClockInDate])+1,[ClockInDate])

evaluates to DateAdd("d",-2,07/04/2006) {{Subtract
2 days from 7/4/6}}

WeekOf: 07/02/2006

The formula will always calculate the Sunday of the week in which the
date exists.

Ron

Jul 11 '06 #5
Got it Ron2006!

Thank you!
Ron2006 wrote:
WeekOf is the field being calculated

The Dateadd function says to add something to a date - The date being
added to is the field at the end ([ClockInDate])

The "d" says to add days to the date

The expression "-Weekday([ClockInDate])+1" is computing how many days
to add. (This number can be negative - in which case it is actually
subtracting days from the date)

Weekday([ClockInDate]) says give me the day of the week. (July 4
which is a Tuesday would give me a 3)

If the Clockindate is July 4, 2006
The "-Weekday([ClockInDate])+1" expressing is evaluated as
follows:

((-1) * 3) + 1
-3 + 1
-2

consequently

WeekOf: DateAdd("d",-Weekday([ClockInDate])+1,[ClockInDate])

evaluates to DateAdd("d",-2,07/04/2006) {{Subtract
2 days from 7/4/6}}

WeekOf: 07/02/2006

The formula will always calculate the Sunday of the week in which the
date exists.

Ron
Jul 11 '06 #6

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

Similar topics

5
3196
by: Eric Linders | last post by:
Hello, Today is Thursday, August 18, 2004. I would like to have a variable that stores the date this coming Sunday (even if today happened to be Sunday) in YYY-MM-DD format. I also need a...
5
7881
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...
1
1728
by: rock72 | last post by:
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...
4
6283
by: Morten Wennevik | last post by:
In an earlier thread I said first day of week was defined as monday, not sunday and forgot all about the thread, so I never got to reply on where it says that. So here it is. ISO 8601 -...
9
3225
by: griemer | last post by:
Hi every one, Is there a way to calculate the timestamp of 00:00:00 last Sunday. For me, this is the begin of the current week.. Or, how old is this week, in seconds Any ideas? Regards,
7
8027
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...
13
2237
by: Mark | last post by:
Dear folks, In Javascript, is it possible to get all id names within, say, a <div></divpair? Like the array of "document.images", I mean. The reason I ask, is that I have a calender whose...
5
13699
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...
5
14855
by: Man4ish | last post by:
Hi, i am coding one program by using string class but i want to replace it with const char* in order to enhance the performance. Sample code: vector <string> vec; char str =...
0
7094
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7123
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7173
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7305
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5427
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4863
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.