473,387 Members | 1,575 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,387 software developers and data experts.

Query by 24 hour Shift

Access 2003

I need to create a query to view data by 3 - 24 hour shifts. Ex: There
are 3 shifts, each shift is 24 hours starting at 0700 through 0700.
Each shift is designated as A, B, or C. 01/01/2006 is an "A" shift.

The data does have a date field that contains both date and time.

Could anyone point me in the right direction to get started?

Any and All help truly appreciated!
Dale

Mar 2 '06 #1
2 2912
mt****@yadtel.net wrote:
Access 2003

I need to create a query to view data by 3 - 24 hour shifts. Ex: There
are 3 shifts, each shift is 24 hours starting at 0700 through 0700.
Each shift is designated as A, B, or C. 01/01/2006 is an "A" shift.

The data does have a date field that contains both date and time.

Could anyone point me in the right direction to get started?

Any and All help truly appreciated!
Dale

Just some random thoughts.

One thing to remember while designing queries is that if you stuff a
field with a Now() value (date and time), it is not the same as a Date()
stuff (date and time of 00:00:00). Let's say you want to check for
something between March 1 and March 2. Using dates only, you can query
on that. If you use time, you need to specify times also. For example,
if you asked to get something between March 1 and March 2, it would only
retrieve those records between March 1 at 00:00:00 and March 2 at
00:00:00.

You might want to add an extra field, called DateOfShift. Sure, you can
calc out the date from your date/time field, but someone may start their
second shift after midnight and could be excluded. So stuff DateOfShift
with the date (no time). Less calcs later on. Thus you could query from
records with a start date of March 2 and then by shift category, and
then start date/time.
Mar 2 '06 #2
I was faced to the same issue. I added another field for the date of start
of the shift which is populated by a function (that could be simplified
again)
Public Function DateStartShUpd(sh As String, DateStart As Date) As Date

On Error GoTo err_DateStartShUpd

Dim ShEnd As Date, DayNo As Integer, d0 As Date, HrBegin As Date, UpdStatus
As Integer, UpdStatusInfo As String

DayNo = WeekDay(DateStart)

Select Case WeekDay(DateStart)
Case 1
HrBegin = Nz(DLookup("sSundayBegin", "tblShift", "ShiftNo='" & sh &
"'"), "")
Case 2
HrBegin = Nz(DLookup("sMondayBegin", "tblShift", "ShiftNo='" & sh &
"'"), "")
Case 3
HrBegin = Nz(DLookup("sTuesdayBegin", "tblShift", "ShiftNo='" & sh &
"'"), "")
Case 4
HrBegin = Nz(DLookup("sWednesdayBegin", "tblShift", "ShiftNo='" & sh &
"'"), "")
Case 5
HrBegin = Nz(DLookup("sThursdayBegin", "tblShift", "ShiftNo='" & sh &
"'"), "")
Case 6
HrBegin = Nz(DLookup("sFridayBegin", "tblShift", "ShiftNo='" & sh &
"'"), "")
Case 7
HrBegin = Nz(DLookup("sSaturdayBegin", "tblShift", "ShiftNo='" & sh &
"'"), "")

End Select

d0 = Format(DateStart, "yyyy-mm-dd")

If Format(HrBegin, "hh:nn") <= Format(DateStart, "hh:nn") Then
DateStartShUpd = d0
Else
DateStartShUpd = DateAdd("d", -1, d0)
End If
exit_DateStartShUpd:

Exit Function

err_DateStartShUpd:
If Err.Number = 94 Then
MsgBox Err.Number & " " & Err.Description
'MsgBox "Work shift starting hour or duration invalid."
Resume Next
'Exit Function
End If

End Function

<mt****@yadtel.net> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
Access 2003

I need to create a query to view data by 3 - 24 hour shifts. Ex: There
are 3 shifts, each shift is 24 hours starting at 0700 through 0700.
Each shift is designated as A, B, or C. 01/01/2006 is an "A" shift.

The data does have a date field that contains both date and time.

Could anyone point me in the right direction to get started?

Any and All help truly appreciated!
Dale

Mar 3 '06 #3

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

Similar topics

5
by: angelasg | last post by:
I am working with employee schedules. Each schedule is comprised of segments (shift, lunch, break, training, etc.) that have rankings. Each record has the employee id, the date the shift starts,...
3
by: Mark Reed | last post by:
Hi all, I have a query at the moment which shows what people have been doing on a certain department throughout an entire shift. It shows the start (Min) time and end (Max) time and then shows...
1
by: Michelle | last post by:
Hi all I am having problems creating an update query. I have 2 tables, tblPublishRoster and tblCCAgents_Changed_Shifts. I want to select all records from tblCCAgents_ChangedShifts where...
5
by: Brooks Clayton | last post by:
I have an A97 db on Win2k machine. I have a make table query to update a small db wich we then FTP to our website for customer order status. What is the best way to automate the query to run...
2
by: Keith C. Perry | last post by:
Ok, I've tried a number of things here and I know I'm missing something but at this point my head is spinning (i.e. lack of sleep, too much coffee, etc...) My environment is PG 7.4.3 on Linux...
3
by: hharriel | last post by:
Hi All, I have created an update query related to high school course information (name of course; credit hour; course description, etc.) I am updating a master course information table. I am...
2
by: Trees | last post by:
I have a query I am trying to create based on another query (inventory) and a table. The inventory query shows the date, shift, Die set and the # of shifts remaining for each die set in...
0
by: Massimiliano Campagnoli | last post by:
Good morning, I have a table like (Date, Hour, Value) where Date can be any date, Hour is always between 6 (6am) to 22 (10pm) and Value is an integer. E.G. Date Hour Value...
5
by: hassanhundal007 | last post by:
In my table the field of DateTime name is TIN. In this field DATE and TIME are shown for date I pass this query: SELECT DAY(TIN) FROM SHIFT WHERE SHID = 1 Then the result is "10". So the same I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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
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
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,...

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.