I have a database (datatrek.mdb) with a table named DATA.
The table has a date/time field [DatumTimeStamp] with default
value = Now(). It has 100 records in it entered over a 50-minute
period.
I would like the query to display 100 records with a new, calculated
field showing timelapse between time of record entry of current record
and time of entry of previous record. For the first record in the
dynaset, I'll settle for a value = 30 seconds. For the last 99 records
in the dynaset, I want to see the ACTUAL time-diffs between the
current and prior record.
Can I make a query do that somehow? 9 2879
For what its worth, I am hoping that a query can be created
to do what I've described in order to avoid an additional data
field in the table to house the absolute timelapse data.
MLH wrote: I have a database (datatrek.mdb) with a table named DATA. The table has a date/time field [DatumTimeStamp] with default value = Now(). It has 100 records in it entered over a 50-minute period.
I would like the query to display 100 records with a new, calculated field showing timelapse between time of record entry of current record and time of entry of previous record. For the first record in the dynaset, I'll settle for a value = 30 seconds. For the last 99 records in the dynaset, I want to see the ACTUAL time-diffs between the current and prior record.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Perhaps:
SELECT DatumTimeStamp,
DateDiff("s", (SELECT Max(DatumTimeSt amp)
FROM [Data]
WHERE DatumTimeStamp < t.DatumTimeStam p),
DatumTimeStamp) As SecondsTimeLaps e
FROM [Data] As t
You could also use the DMax() function instead of the subquery.
See the Access Help articles on DateDiff() and DMax() for more info.
--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQjONx4echKq OuFEgEQKMBQCg9o uDLbjDIhcoH2CAq wAS6EVYfgoAoL7U
QkLQpxT3afDjQ44 W/S/vxaKn
=RGfs
-----END PGP SIGNATURE-----
Hey! That worked! How in the heck did you do that, man?
You're a genius!
xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxx Perhaps:
SELECT DatumTimeStamp, DateDiff("s", (SELECT Max(DatumTimeSt amp) FROM [Data] WHERE DatumTimeStamp < t.DatumTimeStam p), DatumTimeStamp) As SecondsTimeLaps e
FROM [Data] As t
You could also use the DMax() function instead of the subquery.
See the Access Help articles on DateDiff() and DMax() for more info.
MLH wrote: Hey! That worked! How in the heck did you do that, man? You're a genius!
I'd like to take credit for it, but I devised it based on info in a
Query Examples db provided by Microsoft. http://www.microsoft.com/downloads/d...displaylang=en
--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)
MLH <CR**@NorthStat e.net> wrote in message news:<ak******* *************** **********@4ax. com>... I have a database (datatrek.mdb) with a table named DATA. The table has a date/time field [DatumTimeStamp] with default value = Now(). It has 100 records in it entered over a 50-minute period.
I would like the query to display 100 records with a new, calculated field showing timelapse between time of record entry of current record and time of entry of previous record. For the first record in the dynaset, I'll settle for a value = 30 seconds. For the last 99 records in the dynaset, I want to see the ACTUAL time-diffs between the current and prior record.
Can I make a query do that somehow?
This can be done. Depends on what you consider the "previous" record.
You can use a subquery such as the following if you're comparing based
on date.
SELECT *, DateDiff("s", (SELECT TOP 1 DatumTimeStamp FROM DATA WHERE
DatumTimeStamp < D.DatumTimeStam p ORDER BY DatumTimeStamp ASC),
D.DatumTimeStam p)
FROM DATA AS D
If you want to compare based on ID values, just change the inner WHERE
clause to compare the IDs using the same idea.\
HTH,
Russell Sinclair
Could the SQL be taken one step further to never show more than 60
in the [SecondsTimeLaps e] field of the query? In other words, any
value greater than 60 calculated by the DateDiff expression would be
shown simply as 60. Wanna take a stab at that?
Well, I tried this. It worked. I'm happy.
SELECT t.DatumTimeStam p AS Expr1, IIf(DateDiff("s ",(SELECT
Max(DatumTimeSt amp)
FROM [tblDataTESTING]
WHERE DatumTimeStamp <
t.DatumTimeStam p),[DatumTimeStamp])>60,60,DateDif f("s",(SELECT
Max(DatumTimeSt amp)
FROM [tblDataTESTING]
WHERE DatumTimeStamp <
t.DatumTimeStam p),[DatumTimeStamp])) AS SecondsTimeLaps e
FROM tblDataTESTING AS t;
In the final analysis, this gave me PRECISELY what I needed...
SELECT t.DatumTimeStam p AS Expr1, IIf(DateDiff("s ",(SELECT
Max(DatumTimeSt amp)
FROM [tblDataTESTING]
WHERE DatumTimeStamp <
t.DatumTimeStam p),[DatumTimeStamp])>60 or IsNull(DateDiff ("s",(SELECT
Max(DatumTimeSt amp)
FROM [tblDataTESTING]
WHERE DatumTimeStamp <
t.DatumTimeStam p),[DatumTimeStamp])),60,DateDiff( "s",(SELECT
Max(DatumTimeSt amp)
FROM [tblDataTESTING]
WHERE DatumTimeStamp <
t.DatumTimeStam p),[DatumTimeStamp])) AS SecondsTimeLaps e
FROM tblDataTESTING AS t;
Thx again, Mr Foster.
MLH wrote: In the final analysis, this gave me PRECISELY what I needed...
< snip > Thx again, Mr Foster.
You're welcome.
--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: mm nn |
last post by:
Hi,
I want to create a table like this:
ID Autonum
Datefld Date
Cat Text
Itm Text
tCount Number
|
by: Wilder |
last post by:
I'm trying to update a field in one table with the minimum values of
the field in another table. The two tables are linked via a common
field. I want to populate a date field in one table with the earliest
date in another table where the linking fields values are equal. I
set up a query with the two tables, made sure the common fields were
linked, set the query as an "update" query, placed the field and table
I want to update in the...
|
by: Glenn P. |
last post by:
Sorry, CDMA, I searched this NG on several combinations of words, but
I didn't find a relevant hit, so here's my newbie question:
I have an Access 2002 table which contains data extracted from Oracle
9i for a specific date. The table is then queried and about 15
different reports are generated, based upon those queries. My problem
is that I'm now developing several new reports (I haven't used Access
since 1996) and I discovered that each...
|
by: rednexgfx_k |
last post by:
All,
Problem Summary: I've running about 30 make table queries via VBA in
Access 2000, and my database goes from 14,000k to over 2,000,000k. In
addition, the longer the procedure runs, the bigger the performance hit
VBA takes. I'm wondering how to prevent or reduce this.
Details: I have a database table of queries I want to run. This table
contains the query name, the SQL text of the query, the name of the
target table, and whether...
|
by: Dixie |
last post by:
How can I programatically, take some Date/Time fields present in a table in
the current database and change their type to text?
dixie
| |
by: x |
last post by:
hi
i am a pilot by profession. i want to create a database of my logbook
using ms access 2002. i am facing a problem regarding the format of
time field. when i select "Data/Time" data type for my time field then
this format gives the liberty to record times uptill a figure of 59 in
different sub-formats, whereas i want the format to be able to record
the times like 80:35 or 1:10 or 1138:00. which means that i have these
many hours on a...
|
by: laurentc |
last post by:
Dear all,
I have several tables based on exactly the same fields
(Key/Date/Price1/Price2).
I do some statistics on the prices.
However, as I have many different tables (the tables are different
because I directly import the data from a .csv file), I do not want to
create dozens of queries to be able to get the results of the different
tables.
|
by: sesling |
last post by:
I need some help with a date/time field. We run several processing jobs each day. The start and end times are stored in separate columns. The data is stored as date and time. I want to run a query that will sum the total run time of the jobs over a period of several days.
Currently I get the run time by subtracting the end time from the start time. I use the short time format to get it to display the time only.
Ex. 11/30/2006...
|
by: debi.robarts |
last post by:
Ok, in my database I have something like this:
Date One
# of Days to Next Date
These calculate a field "Date Two."
Because "Date Two" is an expression (calculated by the form), I can't
set the control source to save to a field in my table. How can I save
that value to my table?
|
by: tomash |
last post by:
Hi!
I ve got two tables in Access 2007.
I want to update a field of DataTable from another table, DataSumTable when two of their fields equals.
( the fields : Name and Period)
I tried this sql code:
UPDATE DataTable
|
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,...
| |
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...
|
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...
|
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...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
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...
| |
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
|
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...
| | |