473,803 Members | 3,306 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Monday --> Sunday

Currently I am running the following query:

SELECT DateFilter.Empl oyee, DateFilter.Time TypeIn,
sectodur(IIf(Su m(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.Empl oyee, DateFilter.Time TypeIn,
DateAdd("d",-Weekday([ClockInDate]),[ClockInDate])+1
HAVING (((DateFilter.T imeTypeIn)="Reg ular"));
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 2370
Here is an example of a similar problem I solved some time ago. In my
example, the week started on Monday:

SELECT tblEmployee.Emp ID, [EmpFirstName] & " " & [EmpLastName] AS EmpName,
tblTimeEntry.Em pJobSite, tblJobSite.JobS ite, tblJobSite.JobA ddress,
tblJobSite.JobC ity, tblJobSite.JobS tate, tblJobSite.JobZ ip,
tblJobSite.JobS tartDate, tblJobSite.JobE ndDate, tblJobSite.JobS iteName,
tblJobSite.JobS iteClientCode, Format([InTimeStamp],"ww",2) AS weekNum
FROM tblJobSite INNER JOIN (tblEmployee INNER JOIN tblTimeEntry ON
tblEmployee.Emp ID = tblTimeEntry.Em pID) ON tblJobSite.JobI D =
tblTimeEntry.Em pJobSite
GROUP BY tblEmployee.Emp ID, [EmpFirstName] & " " & [EmpLastName],
tblTimeEntry.Em pJobSite, tblJobSite.JobS ite, tblJobSite.JobA ddress,
tblJobSite.JobC ity, tblJobSite.JobS tate, tblJobSite.JobZ ip,
tblJobSite.JobS tartDate, tblJobSite.JobE ndDate, tblJobSite.JobS iteName,
tblJobSite.JobS iteClientCode, 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.goo glegroups.com.. .
Currently I am running the following query:

SELECT DateFilter.Empl oyee, DateFilter.Time TypeIn,
sectodur(IIf(Su m(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.Empl oyee, DateFilter.Time TypeIn,
DateAdd("d",-Weekday([ClockInDate]),[ClockInDate])+1
HAVING (((DateFilter.T imeTypeIn)="Reg ular"));
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.Emp ID, [EmpFirstName] & " " & [EmpLastName] AS EmpName,
tblTimeEntry.Em pJobSite, tblJobSite.JobS ite, tblJobSite.JobA ddress,
tblJobSite.JobC ity, tblJobSite.JobS tate, tblJobSite.JobZ ip,
tblJobSite.JobS tartDate, tblJobSite.JobE ndDate, tblJobSite.JobS iteName,
tblJobSite.JobS iteClientCode, Format([InTimeStamp],"ww",2) AS weekNum
FROM tblJobSite INNER JOIN (tblEmployee INNER JOIN tblTimeEntry ON
tblEmployee.Emp ID = tblTimeEntry.Em pID) ON tblJobSite.JobI D =
tblTimeEntry.Em pJobSite
GROUP BY tblEmployee.Emp ID, [EmpFirstName] & " " & [EmpLastName],
tblTimeEntry.Em pJobSite, tblJobSite.JobS ite, tblJobSite.JobA ddress,
tblJobSite.JobC ity, tblJobSite.JobS tate, tblJobSite.JobZ ip,
tblJobSite.JobS tartDate, tblJobSite.JobE ndDate, tblJobSite.JobS iteName,
tblJobSite.JobS iteClientCode, 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.goo glegroups.com.. .
Currently I am running the following query:

SELECT DateFilter.Empl oyee, DateFilter.Time TypeIn,
sectodur(IIf(Su m(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.Empl oyee, DateFilter.Time TypeIn,
DateAdd("d",-Weekday([ClockInDate]),[ClockInDate])+1
HAVING (((DateFilter.T imeTypeIn)="Reg ular"));
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.Emp ID, [EmpFirstName] & " " & [EmpLastName] AS EmpName,
tblTimeEntry.Em pJobSite, tblJobSite.JobS ite, tblJobSite.JobA ddress,
tblJobSite.JobC ity, tblJobSite.JobS tate, tblJobSite.JobZ ip,
tblJobSite.JobS tartDate, tblJobSite.JobE ndDate, tblJobSite.JobS iteName,
tblJobSite.JobS iteClientCode, Format([InTimeStamp],"ww",2) AS weekNum
FROM tblJobSite INNER JOIN (tblEmployee INNER JOIN tblTimeEntry ON
tblEmployee.Emp ID = tblTimeEntry.Em pID) ON tblJobSite.JobI D =
tblTimeEntry.Em pJobSite
GROUP BY tblEmployee.Emp ID, [EmpFirstName] & " " & [EmpLastName],
tblTimeEntry.Em pJobSite, tblJobSite.JobS ite, tblJobSite.JobA ddress,
tblJobSite.JobC ity, tblJobSite.JobS tate, tblJobSite.JobZ ip,
tblJobSite.JobS tartDate, tblJobSite.JobE ndDate, tblJobSite.JobS iteName,
tblJobSite.JobS iteClientCode, 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.goo glegroups.com.. .
Currently I am running the following query:
>
SELECT DateFilter.Empl oyee, DateFilter.Time TypeIn,
sectodur(IIf(Su m(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.Empl oyee, DateFilter.Time TypeIn,
DateAdd("d",-Weekday([ClockInDate]),[ClockInDate])+1
HAVING (((DateFilter.T imeTypeIn)="Reg ular"));
>
>
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
3213
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 variable that will store the date this past Monday (even if today happens to be Monday) also in YYY-MM-DD format. So, the end result is that, for this week (today is 2004-08-18) I would have the following two variables:
5
7975
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 2005", (or a timestamp that could be formatted). I have been thinking about creating a loop that increases the source date $myDate with 24*60*60 until date("l", $myDate) = "Monday" but maybe I am trying too complicated solutions and overseeing...
1
1738
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 wk days Remark 11/01/04 1
4
6300
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 - International Standard Date and Time Notation "A week starts with Monday (day 1) and ends with Sunday (day 7)."
9
3251
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
8092
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 do? I tried this but it does not work (it is always Sunday): using System.Globalization; .... CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();
13
2280
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 <td></tdtable elements, within a given <div></div>, all have a class type, one of which is "today" (to highlight it). Once the calender is drawn, the Javascript has ended. And since Javascript has no known (to me) method of storing variables in say,...
5
13721
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 heading in the right direction but doesn't quite give me the results I am looking for. $givenday = mktime(0,0,0,10,08,2007); $Monday = strtotime("Monday this week",$givenday); echo date("j M Y H:i:s", $Monday);
5
15145
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 = {"Sunday","Monday"........................} for (int i = 0; i < 10; i++) vec.push_back(str); If i use const char*, there is always memory leak. vector <const char* > vec;
0
9564
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10546
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10068
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9121
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6841
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.