473,569 Members | 2,664 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DateAdd Shift

I have a report that acts as a time sheet for employees. It lists
there "punch-in" and "punch-out and catagorizes them by week, with
different totals..

At the end of each week is a total of all the hours for the week. The
pay week is from Monday -> Sunday, but with the query below, it is
totaling Sunday -> Saturday. Does anyone know how I could "shift" the
work week?

Any help would be great!!!!!!!!!

Thanks!

Brad

This query is TimeClockSum-Individual Week:

//
SELECT Sum(DateDiff("s ",[ClockIn],[ClockOut]))\3600 &
Format((Sum(Dat eDiff("s",[ClockIn],[ClockOut])) Mod
3600)/86400,":nn:ss") AS TotalTime,
DateAdd("d",-Weekday([ClockInDate]),[ClockInDate])+1 AS WeekOf,
[ADateFilter - 1 Week].Employee, [ADateFilter - 1 Week].TimeTypeIn
FROM [ADateFilter - 1 Week]
GROUP BY DateAdd("d",-Weekday([ClockInDate]),[ClockInDate])+1,
[ADateFilter - 1 Week].Employee, [ADateFilter - 1 Week].TimeTypeIn
HAVING ((([ADateFilter - 1 Week].TimeTypeIn)="R egular"));
//
ADateFilter - 1 Week is the following query:

//
SELECT TimeClockHistor y.TimeEventID, TimeClockHistor y.Employee,
TimeClockHistor y.ClockInDate, TimeClockHistor y.ClockIn,
TimeClockHistor y.ReasonClockIn , TimeClockHistor y.TimeTypeIn,
TimeClockHistor y.ClockOutDate, TimeClockHistor y.ClockOut,
TimeClockHistor y.ReasonClockOu t, TimeClockHistor y.TimeTypeOut
FROM TimeClockHistor y
WHERE (((TimeClockHis tory.Employee)=[forms]![EmployeeFilter -
Admin]![cboEmployee]) AND ((TimeClockHist ory.ClockInDate ) Between
[forms]![EmployeeFilter - Admin]![Date1]+2 And [forms]![EmployeeFilter
- Admin]![Date1]-11));
//

Jun 20 '06 #1
4 1832
Drum2001 wrote:
I have a report that acts as a time sheet for employees. It lists
there "punch-in" and "punch-out and catagorizes them by week, with
different totals..

At the end of each week is a total of all the hours for the week. The
pay week is from Monday -> Sunday, but with the query below, it is
totaling Sunday -> Saturday. Does anyone know how I could "shift" the
work week?

Any help would be great!!!!!!!!!

Thanks!

Brad

This query is TimeClockSum-Individual Week:

//
SELECT Sum(DateDiff("s ",[ClockIn],[ClockOut]))\3600 &
Format((Sum(Dat eDiff("s",[ClockIn],[ClockOut])) Mod
3600)/86400,":nn:ss") AS TotalTime,
DateAdd("d",-Weekday([ClockInDate]),[ClockInDate])+1 AS WeekOf,
[ADateFilter - 1 Week].Employee, [ADateFilter - 1 Week].TimeTypeIn
FROM [ADateFilter - 1 Week]
GROUP BY DateAdd("d",-Weekday([ClockInDate]),[ClockInDate])+1,
[ADateFilter - 1 Week].Employee, [ADateFilter - 1 Week].TimeTypeIn
HAVING ((([ADateFilter - 1 Week].TimeTypeIn)="R egular"));
//
ADateFilter - 1 Week is the following query:

//
SELECT TimeClockHistor y.TimeEventID, TimeClockHistor y.Employee,
TimeClockHistor y.ClockInDate, TimeClockHistor y.ClockIn,
TimeClockHistor y.ReasonClockIn , TimeClockHistor y.TimeTypeIn,
TimeClockHistor y.ClockOutDate, TimeClockHistor y.ClockOut,
TimeClockHistor y.ReasonClockOu t, TimeClockHistor y.TimeTypeOut
FROM TimeClockHistor y
WHERE (((TimeClockHis tory.Employee)=[forms]![EmployeeFilter -
Admin]![cboEmployee]) AND ((TimeClockHist ory.ClockInDate ) Between
[forms]![EmployeeFilter - Admin]![Date1]+2 And [forms]![EmployeeFilter
- Admin]![Date1]-11));
//

Don't know if this helps, but WeekDay takes an option second argument
that specifies the first day of the week. Use vbSunday/1 for Sunday as
the start of the week, vbMonday/2 for Monday ect.
Jun 20 '06 #2

salad wrote:
Drum2001 wrote:
I have a report that acts as a time sheet for employees. It lists
there "punch-in" and "punch-out and catagorizes them by week, with
different totals..

At the end of each week is a total of all the hours for the week. The
pay week is from Monday -> Sunday, but with the query below, it is
totaling Sunday -> Saturday. Does anyone know how I could "shift" the
work week?

Any help would be great!!!!!!!!!

Thanks!

Brad

This query is TimeClockSum-Individual Week:

//
SELECT Sum(DateDiff("s ",[ClockIn],[ClockOut]))\3600 &
Format((Sum(Dat eDiff("s",[ClockIn],[ClockOut])) Mod
3600)/86400,":nn:ss") AS TotalTime,
DateAdd("d",-Weekday([ClockInDate]),[ClockInDate])+1 AS WeekOf,
[ADateFilter - 1 Week].Employee, [ADateFilter - 1 Week].TimeTypeIn
FROM [ADateFilter - 1 Week]
GROUP BY DateAdd("d",-Weekday([ClockInDate]),[ClockInDate])+1,
[ADateFilter - 1 Week].Employee, [ADateFilter - 1 Week].TimeTypeIn
HAVING ((([ADateFilter - 1 Week].TimeTypeIn)="R egular"));
//
ADateFilter - 1 Week is the following query:

//
SELECT TimeClockHistor y.TimeEventID, TimeClockHistor y.Employee,
TimeClockHistor y.ClockInDate, TimeClockHistor y.ClockIn,
TimeClockHistor y.ReasonClockIn , TimeClockHistor y.TimeTypeIn,
TimeClockHistor y.ClockOutDate, TimeClockHistor y.ClockOut,
TimeClockHistor y.ReasonClockOu t, TimeClockHistor y.TimeTypeOut
FROM TimeClockHistor y
WHERE (((TimeClockHis tory.Employee)=[forms]![EmployeeFilter -
Admin]![cboEmployee]) AND ((TimeClockHist ory.ClockInDate ) Between
[forms]![EmployeeFilter - Admin]![Date1]+2 And [forms]![EmployeeFilter
- Admin]![Date1]-11));
//

Don't know if this helps, but WeekDay takes an option second argument
that specifies the first day of the week. Use vbSunday/1 for Sunday as
the start of the week, vbMonday/2 for Monday ect..


What would I put exatly and where. I replaced -Weekday with vbSunday/1
and recieved a syntax error. I then took out the "/1" and the query
ran, however, did not produce any results for this query now.

Jun 20 '06 #3
On 20 Jun 2006 07:57:10 -0700, Drum2001 wrote:
salad wrote:
Drum2001 wrote:
I have a report that acts as a time sheet for employees. It lists
there "punch-in" and "punch-out and catagorizes them by week, with
different totals..

At the end of each week is a total of all the hours for the week. The
pay week is from Monday -> Sunday, but with the query below, it is
totaling Sunday -> Saturday. Does anyone know how I could "shift" the
work week?

Any help would be great!!!!!!!!!

Thanks!

Brad

This query is TimeClockSum-Individual Week:

//
SELECT Sum(DateDiff("s ",[ClockIn],[ClockOut]))\3600 &
Format((Sum(Dat eDiff("s",[ClockIn],[ClockOut])) Mod
3600)/86400,":nn:ss") AS TotalTime,
DateAdd("d",-Weekday([ClockInDate]),[ClockInDate])+1 AS WeekOf,
[ADateFilter - 1 Week].Employee, [ADateFilter - 1 Week].TimeTypeIn
FROM [ADateFilter - 1 Week]
GROUP BY DateAdd("d",-Weekday([ClockInDate]),[ClockInDate])+1,
[ADateFilter - 1 Week].Employee, [ADateFilter - 1 Week].TimeTypeIn
HAVING ((([ADateFilter - 1 Week].TimeTypeIn)="R egular"));
//
ADateFilter - 1 Week is the following query:

//
SELECT TimeClockHistor y.TimeEventID, TimeClockHistor y.Employee,
TimeClockHistor y.ClockInDate, TimeClockHistor y.ClockIn,
TimeClockHistor y.ReasonClockIn , TimeClockHistor y.TimeTypeIn,
TimeClockHistor y.ClockOutDate, TimeClockHistor y.ClockOut,
TimeClockHistor y.ReasonClockOu t, TimeClockHistor y.TimeTypeOut
FROM TimeClockHistor y
WHERE (((TimeClockHis tory.Employee)=[forms]![EmployeeFilter -
Admin]![cboEmployee]) AND ((TimeClockHist ory.ClockInDate ) Between
[forms]![EmployeeFilter - Admin]![Date1]+2 And [forms]![EmployeeFilter
- Admin]![Date1]-11));
//

Don't know if this helps, but WeekDay takes an option second argument
that specifies the first day of the week. Use vbSunday/1 for Sunday as
the start of the week, vbMonday/2 for Monday ect..


What would I put exatly and where. I replaced -Weekday with vbSunday/1
and recieved a syntax error. I then took out the "/1" and the query
ran, however, did not produce any results for this query now.


My comments are regarding the use of the Weekday function only, not
whether your SQL will return the correct records.

Did you not read VBA help on the Weekday function?
vbSunday is the default week start, so at the very least, you would
need vbMonday.
Also, in a query, you cannot use the VB constants (as you are not
using VB). Therefore, you would need to use the constant's value. For
vbMonday, that would be 2, i.e. WeekDay([YourFieldName],2)

Read the help files!
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Jun 20 '06 #4
Actually Fred,

I did read the help files, but I did not understand the explination.
That is why I asked on the forum.

Thank you for taking the time to correct me.
fredg wrote:
On 20 Jun 2006 07:57:10 -0700, Drum2001 wrote:
salad wrote:
Drum2001 wrote:
I have a report that acts as a time sheet for employees. It lists
there "punch-in" and "punch-out and catagorizes them by week, with
different totals..

At the end of each week is a total of all the hours for the week. The
pay week is from Monday -> Sunday, but with the query below, it is
totaling Sunday -> Saturday. Does anyone know how I could "shift" the
work week?

Any help would be great!!!!!!!!!

Thanks!

Brad

This query is TimeClockSum-Individual Week:

//
SELECT Sum(DateDiff("s ",[ClockIn],[ClockOut]))\3600 &
Format((Sum(Dat eDiff("s",[ClockIn],[ClockOut])) Mod
3600)/86400,":nn:ss") AS TotalTime,
DateAdd("d",-Weekday([ClockInDate]),[ClockInDate])+1 AS WeekOf,
[ADateFilter - 1 Week].Employee, [ADateFilter - 1 Week].TimeTypeIn
FROM [ADateFilter - 1 Week]
GROUP BY DateAdd("d",-Weekday([ClockInDate]),[ClockInDate])+1,
[ADateFilter - 1 Week].Employee, [ADateFilter - 1 Week].TimeTypeIn
HAVING ((([ADateFilter - 1 Week].TimeTypeIn)="R egular"));
//
ADateFilter - 1 Week is the following query:

//
SELECT TimeClockHistor y.TimeEventID, TimeClockHistor y.Employee,
TimeClockHistor y.ClockInDate, TimeClockHistor y.ClockIn,
TimeClockHistor y.ReasonClockIn , TimeClockHistor y.TimeTypeIn,
TimeClockHistor y.ClockOutDate, TimeClockHistor y.ClockOut,
TimeClockHistor y.ReasonClockOu t, TimeClockHistor y.TimeTypeOut
FROM TimeClockHistor y
WHERE (((TimeClockHis tory.Employee)=[forms]![EmployeeFilter -
Admin]![cboEmployee]) AND ((TimeClockHist ory.ClockInDate ) Between
[forms]![EmployeeFilter - Admin]![Date1]+2 And [forms]![EmployeeFilter
- Admin]![Date1]-11));
//

Don't know if this helps, but WeekDay takes an option second argument
that specifies the first day of the week. Use vbSunday/1 for Sunday as
the start of the week, vbMonday/2 for Monday ect..


What would I put exatly and where. I replaced -Weekday with vbSunday/1
and recieved a syntax error. I then took out the "/1" and the query
ran, however, did not produce any results for this query now.


My comments are regarding the use of the Weekday function only, not
whether your SQL will return the correct records.

Did you not read VBA help on the Weekday function?
vbSunday is the default week start, so at the very least, you would
need vbMonday.
Also, in a query, you cannot use the VB constants (as you are not
using VB). Therefore, you would need to use the constant's value. For
vbMonday, that would be 2, i.e. WeekDay([YourFieldName],2)

Read the help files!
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


Jun 20 '06 #5

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

Similar topics

5
6855
by: lofty | last post by:
Dear Lord, I'm trying to code a drop down for a date entry that gives the user the option of the current date plus the dates of the last 7 days. <% for i = -7 to -1 Response.write "<option>" & DateAdd(d,i,Date()) & "<option>"
4
10060
by: Øyvind Isaksen | last post by:
Hi! I need to add 1 day to a specific date. The date have is stored in a variable called "DateOld". The value of the variable have this syntax: mm.dd.yyyy. The new date is the variable called "DateNew". This is my code that dont work: DateNew = DATEADD(d,1,DateOld)
9
5518
by: Brandon | last post by:
Greetings, I am having a problem getting a SQL statement that is functional in Access 2K to work in ASP. My Access SQL statement is this: SELECT DateAdd('s',Ticket_Opened_Date,'Dec 31, 1969 8:00:00PM') AS Opened_Date, AL.Last_Significant_Update_Date AS Last_Updated, AL.Due_Date AS Ticket_Due_Date, AL.Managing_Station,
1
17313
by: Raghu | last post by:
Hello... I am running into a problem while running a query..can some1 help.. this is the query : ************** SELECT * from Table S where S.dtDate1 BETWEEN dateadd(year,1,dateadd(month,-1,getdate())) AND dateadd(day,-1,(dateadd(month,1,dateadd(year,1,dateadd(month,-1,getdate()))))) *************** (first part of the date calculation...
2
37604
by: Abdul N K | last post by:
I need help in T-SQL. I am using DATEADD function and I want to add 6 months to a date. But it does not return me the rusults, which I want e.g. SELECT DATEADD(m,'20040630') returns 20041230 which is logical correct? But I want it to return end of month (i.e. 20041231) Any help in this context will be highly appreciated
3
3713
by: Annette Massie | last post by:
I am trying to insert a record into a table via code and one of the values to add I would like as a dateadd calculation on a value from a query. My code looks like this: Set db = CurrentDb() ' if the table is in the same database Set rsAdd = db.OpenRecordset("tblClientTreatment") With rsAdd .AddNew !ClientID = Me.ClientID
4
10147
by: ey.markov | last post by:
Greetings, I have an A2K application where for a report the user enters a month-end date, and the system must gather transactions for that month. No problem, I thought, I'll just use the DateAdd function for the beginning of the date range, like this: Between DateAdd("m",-1,!!) And !!
1
18984
by: C.Davidson | last post by:
Does subject VB.net 2003 support DateAdd function? I have tried to implement the following without success. In my example I tried to simply add 30 months to 9/18/2003 and I get "New date: 12:00:00 AM", no date Example direct from VB Language Reference: Public Overloads Function DateAdd(ByVal Interval As DateInterval,_ ByVal Number As...
2
4547
by: Rich Raffenetti | last post by:
I have the following code. If I do the dateadd function with dateinterval.minute, it works fine and the date/time value is displayed with zero seconds. If I do the dateadd function with dateinterval.second, an error is thrown saying I have an overflow. I would be happy to know if I am doing something wrong or if I could do it differently to...
0
7698
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
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...
0
7970
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...
0
6284
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...
1
5513
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
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...
0
3653
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...
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.