Hi all,
I have a query (query1) which shows scan date, scan time & operator. One
scan = 1 record. What I want to do is create a report based on query 2 from
query1 which shows all the scans AND the difference between each scan.
Something like below. I have spent days on this and can't figure it out.
Date Time Login Diff
04-Dec-03 23:33:12 27478
04-Dec-03 23:33:38 27478 00:00:26
04-Dec-03 23:34:00 27478 00:00:22
04-Dec-03 23:34:21 27478 00:00:21
04-Dec-03 23:35:11 27478 00:00:50
Thanks in advance
Mark 4 4199
Use a subquery to get the most recent login date and time for the same login
number.
That's a matter of typing something like this into the Field row of your
query to create the calculated field:
Seconds: DateDiff("s", (MyTable.Date + MyTable.Time),
(SELECT TOP 1 (Dupe.Date + Dupe.Time) AS PriorTime
FROM MyTable AS Dupe
WHERE ((Dupe.Login = MyTable.Login) AND ((Dupe.Date + Dupe.Time) <
(Mytable.Date + MyTable.Time)))
ORDER BY Dupe.Date DESC; Dupe.Time DESC ) )
This would be considerably more efficient if the date and time were stored
in the one field. Hopefully your fields are not actually called Date and
Time as theser are reserved words in VBA.
Consider adding the primary key to the ORDER BY clause as well, so Access
can distinguish between 2 records that have exactly the same date and time.
If you want the time as a string instead of a number of seconds, see: http://members.rogers.com/douglas.j....iff2Dates.html
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Mark Reed" <ma*********@ntlworld.com> wrote in message
news:hN************@newsfep3-gui.server.ntli.net... Hi all, I have a query (query1) which shows scan date, scan time & operator.
One scan = 1 record. What I want to do is create a report based on query 2
from query1 which shows all the scans AND the difference between each scan. Something like below. I have spent days on this and can't figure it out.
Date Time Login Diff 04-Dec-03 23:33:12 27478 04-Dec-03 23:33:38 27478 00:00:26 04-Dec-03 23:34:00 27478 00:00:22 04-Dec-03 23:34:21 27478 00:00:21 04-Dec-03 23:35:11 27478 00:00:50
Thanks for that Allen,
I've tried what you have suggest but I think I am doing something wrong.
I'll give you a little more background to my problem as I think that may be
the cause.
The database gets it's inputs from a txt file recovered from the works
management system when I run a SQL within it. Towards the end of shift,
there could be anything up to 18,000 entries as the WMS SQL asks for every
single scan during a set shift. The results of that SQL are then pasted into
a single field of my Access database.
Example of txt result is:
04-DEC-2003 22:21:09 Chowdry, Halim 06313 988558 -6 N5608D CCS
LOCA 1 H Picking 14310 725997 Conv
Conv -6 04.12.03H 3
04-DEC-2003 22:22:16 Phillips, Lillian 46517H 988567 -1 N6909A CCS
LOCA 1 H Picking 14362 681311 Conv
Conv -1 04.12.03H 3
My first query ([decode1]) breaks the txt file into relevant fields. The
second ([decode2]) then changes the some of the fields into values and time
rather than just text.
SELECT DISTINCT DateValue([decode].[Date]) AS actdate,
TimeValue([Decode]![Time]) AS acttime, [Name query].[First Name], [Name
query].Surname, Decode.Operator, Decode.[Pic Route], Val([Decode]![QTY]) AS
Qty, Val([Decode]![IP Qty]) AS [IP Qty], Decode.Location, Decode.[To
Location], Decode.Cartons, Decode.PT, Decode.Job, Val([Decode]![RDT]) AS
RDT, Val([Decode]![Trolley]) AS Trolley, Decode.Fromst, Decode.Tost,
Decode.Schedule, Decode.Wv
FROM [Name query] INNER JOIN Decode ON [Name query].Login = Decode.Operator
GROUP BY DateValue([decode].[Date]), TimeValue([Decode]![Time]), [Name
query].[First Name], [Name query].Surname, Decode.Operator, Decode.[Pic
Route], Val([Decode]![QTY]), Val([Decode]![IP Qty]), Decode.Location,
Decode.[To Location], Decode.Cartons, Decode.PT, Decode.Job,
Val([Decode]![RDT]), Val([Decode]![Trolley]), Decode.Fromst, Decode.Tost,
Decode.Schedule, Decode.Wv
WITH OWNERACCESS OPTION;
All of the other querys in the DB are based on the decode2 query.
How would you write the query, given the above information to show the time
difference between each record?
I really appreciate your help with this.
Regards,
Mark
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:40**********************@freenews.iinet.net.a u... Use a subquery to get the most recent login date and time for the same
login number.
That's a matter of typing something like this into the Field row of your query to create the calculated field:
Seconds: DateDiff("s", (MyTable.Date + MyTable.Time), (SELECT TOP 1 (Dupe.Date + Dupe.Time) AS PriorTime FROM MyTable AS Dupe WHERE ((Dupe.Login = MyTable.Login) AND ((Dupe.Date + Dupe.Time) < (Mytable.Date + MyTable.Time))) ORDER BY Dupe.Date DESC; Dupe.Time DESC ) )
This would be considerably more efficient if the date and time were stored in the one field. Hopefully your fields are not actually called Date and Time as theser are reserved words in VBA.
Consider adding the primary key to the ORDER BY clause as well, so Access can distinguish between 2 records that have exactly the same date and
time. If you want the time as a string instead of a number of seconds, see: http://members.rogers.com/douglas.j....iff2Dates.html -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org.
"Mark Reed" <ma*********@ntlworld.com> wrote in message news:hN************@newsfep3-gui.server.ntli.net... Hi all, I have a query (query1) which shows scan date, scan time & operator. One scan = 1 record. What I want to do is create a report based on query 2 from query1 which shows all the scans AND the difference between each scan. Something like below. I have spent days on this and can't figure it out.
Date Time Login Diff 04-Dec-03 23:33:12 27478 04-Dec-03 23:33:38 27478 00:00:26 04-Dec-03 23:34:00 27478 00:00:22 04-Dec-03 23:34:21 27478 00:00:21 04-Dec-03 23:35:11 27478 00:00:50
Hi Mark.
It makes sense to import the text file into an Access table.
Combine the date and time into one Date/Time field, and index it.
Then the subquery should be able to find the correct prior date/time value
from the index (instead of having to scan the 18k records), so it should
perform acceptably.
For more info on how to build the subquery, see:
How to Compare a Field to a Field in a Prior Record
at: http://support.microsoft.com/default...roduct=acc2000
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Mark Reed" <ma*********@ntlworld.com> wrote in message
news:jX**************@newsfep3-gui.server.ntli.net... Thanks for that Allen, I've tried what you have suggest but I think I am doing something
wrong. I'll give you a little more background to my problem as I think that may
be the cause.
The database gets it's inputs from a txt file recovered from the works management system when I run a SQL within it. Towards the end of shift, there could be anything up to 18,000 entries as the WMS SQL asks for every single scan during a set shift. The results of that SQL are then pasted
into a single field of my Access database. Example of txt result is:
04-DEC-2003 22:21:09 Chowdry, Halim 06313 988558 -6 N5608D CCS LOCA 1 H Picking 14310 725997 Conv Conv -6 04.12.03H 3
04-DEC-2003 22:22:16 Phillips, Lillian 46517H 988567 -1 N6909A CCS LOCA 1 H Picking 14362 681311 Conv Conv -1 04.12.03H 3
My first query ([decode1]) breaks the txt file into relevant fields. The second ([decode2]) then changes the some of the fields into values and
time rather than just text.
SELECT DISTINCT DateValue([decode].[Date]) AS actdate, TimeValue([Decode]![Time]) AS acttime, [Name query].[First Name], [Name query].Surname, Decode.Operator, Decode.[Pic Route], Val([Decode]![QTY])
AS Qty, Val([Decode]![IP Qty]) AS [IP Qty], Decode.Location, Decode.[To Location], Decode.Cartons, Decode.PT, Decode.Job, Val([Decode]![RDT]) AS RDT, Val([Decode]![Trolley]) AS Trolley, Decode.Fromst, Decode.Tost, Decode.Schedule, Decode.Wv FROM [Name query] INNER JOIN Decode ON [Name query].Login =
Decode.Operator GROUP BY DateValue([decode].[Date]), TimeValue([Decode]![Time]), [Name query].[First Name], [Name query].Surname, Decode.Operator, Decode.[Pic Route], Val([Decode]![QTY]), Val([Decode]![IP Qty]), Decode.Location, Decode.[To Location], Decode.Cartons, Decode.PT, Decode.Job, Val([Decode]![RDT]), Val([Decode]![Trolley]), Decode.Fromst, Decode.Tost, Decode.Schedule, Decode.Wv WITH OWNERACCESS OPTION;
All of the other querys in the DB are based on the decode2 query.
How would you write the query, given the above information to show the
time difference between each record?
I really appreciate your help with this.
Regards, Mark "Allen Browne" <Al*********@SeeSig.Invalid> wrote in message news:40**********************@freenews.iinet.net.a u... Use a subquery to get the most recent login date and time for the same login number.
That's a matter of typing something like this into the Field row of your query to create the calculated field:
Seconds: DateDiff("s", (MyTable.Date + MyTable.Time), (SELECT TOP 1 (Dupe.Date + Dupe.Time) AS PriorTime FROM MyTable AS Dupe WHERE ((Dupe.Login = MyTable.Login) AND ((Dupe.Date + Dupe.Time) < (Mytable.Date + MyTable.Time))) ORDER BY Dupe.Date DESC; Dupe.Time DESC ) )
This would be considerably more efficient if the date and time were
stored in the one field. Hopefully your fields are not actually called Date and Time as theser are reserved words in VBA.
Consider adding the primary key to the ORDER BY clause as well, so
Access can distinguish between 2 records that have exactly the same date and time. If you want the time as a string instead of a number of seconds, see: http://members.rogers.com/douglas.j....iff2Dates.html
"Mark Reed" <ma*********@ntlworld.com> wrote in message news:hN************@newsfep3-gui.server.ntli.net... Hi all, I have a query (query1) which shows scan date, scan time &
operator. One scan = 1 record. What I want to do is create a report based on query 2 from query1 which shows all the scans AND the difference between each scan. Something like below. I have spent days on this and can't figure it
out. Date Time Login Diff 04-Dec-03 23:33:12 27478 04-Dec-03 23:33:38 27478 00:00:26 04-Dec-03 23:34:00 27478 00:00:22 04-Dec-03 23:34:21 27478 00:00:21 04-Dec-03 23:35:11 27478 00:00:50
Fantastic!!!! Thankyou very much for your help.
Mark
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:40**********************@freenews.iinet.net.a u... Hi Mark.
It makes sense to import the text file into an Access table. Combine the date and time into one Date/Time field, and index it. Then the subquery should be able to find the correct prior date/time value from the index (instead of having to scan the 18k records), so it should perform acceptably.
For more info on how to build the subquery, see: How to Compare a Field to a Field in a Prior Record at:
http://support.microsoft.com/default...roduct=acc2000 -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org.
"Mark Reed" <ma*********@ntlworld.com> wrote in message news:jX**************@newsfep3-gui.server.ntli.net... Thanks for that Allen, I've tried what you have suggest but I think I am doing something wrong. I'll give you a little more background to my problem as I think that may be the cause.
The database gets it's inputs from a txt file recovered from the works management system when I run a SQL within it. Towards the end of shift, there could be anything up to 18,000 entries as the WMS SQL asks for
every single scan during a set shift. The results of that SQL are then pasted into a single field of my Access database. Example of txt result is:
04-DEC-2003 22:21:09 Chowdry, Halim 06313 988558 -6 N5608D
CCS LOCA 1 H Picking 14310 725997 Conv Conv -6 04.12.03H 3
04-DEC-2003 22:22:16 Phillips, Lillian 46517H 988567 -1 N6909A
CCS LOCA 1 H Picking 14362 681311 Conv Conv -1 04.12.03H 3
My first query ([decode1]) breaks the txt file into relevant fields. The second ([decode2]) then changes the some of the fields into values and time rather than just text.
SELECT DISTINCT DateValue([decode].[Date]) AS actdate, TimeValue([Decode]![Time]) AS acttime, [Name query].[First Name], [Name query].Surname, Decode.Operator, Decode.[Pic Route], Val([Decode]![QTY]) AS Qty, Val([Decode]![IP Qty]) AS [IP Qty], Decode.Location, Decode.[To Location], Decode.Cartons, Decode.PT, Decode.Job, Val([Decode]![RDT]) AS RDT, Val([Decode]![Trolley]) AS Trolley, Decode.Fromst, Decode.Tost, Decode.Schedule, Decode.Wv FROM [Name query] INNER JOIN Decode ON [Name query].Login = Decode.Operator GROUP BY DateValue([decode].[Date]), TimeValue([Decode]![Time]), [Name query].[First Name], [Name query].Surname, Decode.Operator, Decode.[Pic Route], Val([Decode]![QTY]), Val([Decode]![IP Qty]), Decode.Location, Decode.[To Location], Decode.Cartons, Decode.PT, Decode.Job, Val([Decode]![RDT]), Val([Decode]![Trolley]), Decode.Fromst,
Decode.Tost, Decode.Schedule, Decode.Wv WITH OWNERACCESS OPTION;
All of the other querys in the DB are based on the decode2 query.
How would you write the query, given the above information to show the time difference between each record?
I really appreciate your help with this.
Regards, Mark "Allen Browne" <Al*********@SeeSig.Invalid> wrote in message news:40**********************@freenews.iinet.net.a u... Use a subquery to get the most recent login date and time for the same login number.
That's a matter of typing something like this into the Field row of
your query to create the calculated field:
Seconds: DateDiff("s", (MyTable.Date + MyTable.Time), (SELECT TOP 1 (Dupe.Date + Dupe.Time) AS PriorTime FROM MyTable AS Dupe WHERE ((Dupe.Login = MyTable.Login) AND ((Dupe.Date + Dupe.Time) < (Mytable.Date + MyTable.Time))) ORDER BY Dupe.Date DESC; Dupe.Time DESC ) )
This would be considerably more efficient if the date and time were stored in the one field. Hopefully your fields are not actually called Date
and Time as theser are reserved words in VBA.
Consider adding the primary key to the ORDER BY clause as well, so Access can distinguish between 2 records that have exactly the same date and
time. If you want the time as a string instead of a number of seconds, see: http://members.rogers.com/douglas.j....iff2Dates.html
"Mark Reed" <ma*********@ntlworld.com> wrote in message news:hN************@newsfep3-gui.server.ntli.net... > Hi all, > I have a query (query1) which shows scan date, scan time & operator. One > scan = 1 record. What I want to do is create a report based on query
2 from > query1 which shows all the scans AND the difference between each
scan. > Something like below. I have spent days on this and can't figure it out. > > Date Time Login Diff > 04-Dec-03 23:33:12 27478 > 04-Dec-03 23:33:38 27478 00:00:26 > 04-Dec-03 23:34:00 27478 00:00:22 > 04-Dec-03 23:34:21 27478 00:00:21 > 04-Dec-03 23:35:11 27478 00:00:50
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: NotGiven |
last post by:
Below is a good elapsed time function I found. However, I'd like to return
total seconds instead of broken down into days, hours, minutes & seconds.
In other words, I want "125" instead of "2...
|
by: Stefan Behnel |
last post by:
Hi!
The logging module nicely prepends each line with a formatted date.
However, I'm not interested in the actual date but only in the number of
milliseconds that passed since the start of the...
|
by: Alberto Santini |
last post by:
I ported a Jos Stam's demo about Fluid mech to check
the difference of speed between C implementation and
Python. I think I achieved good results with Python
and there is space to improve, without...
|
by: Chanchito |
last post by:
hi there,
I am seeking some guidance in regards to creating a query. I would
like to be able to have the query display records that have had a
certain amount of time pass since the time that is...
|
by: MLH |
last post by:
I have a database (datatrek.mdb) with a table named DATA.
The table has a date/time field with default
value = Now(). It has 100 records in it entered over a 50-minute
period.
I would like the...
|
by: Viviana R via AccessMonster.com |
last post by:
I'm tryin to calculate de difference of time between different records and
fields.
I have a Report with date, time In, and Time Out fields.
EX:
Date Time IN Time Out
4/12/05 12:10...
|
by: Richard |
last post by:
Hi,
Is there any way to get the time difference between Central(US) and GMT in
vb.net.
I'll appreciate your help/suggestion.
Thanks
RC
|
by: Jeremy Sanders |
last post by:
Hi - I need to add support to a program for dates and times. The built-in
Python library seems to be okay for many purposes, but what I would like
would be Unix epoch style times (seconds relative...
|
by: Ron Adam |
last post by:
I'm having some cross platform issues with timing loops. It seems
time.time is better for some computers/platforms and time.clock others, but
it's not always clear which, so I came up with the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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
|
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...
|
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: 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...
|
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: 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...
| |