473,656 Members | 2,983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Difference between Time fields? - Access 2000 Query

I'm stuck:
In a query I am trying to compare two fields with a date/time data type and a
LongTime format to get the difference in hours (minutes and seconds if
possible). After that I need to determine if the difference is greater than 5
hours.
The part of the query looks like this so far (IIf([CT]="EQ" AND
([NDTIME]-[STTIME])>5,"Yes","No" ) AS EQChg) but doesn't come out right.
NDTIME = 10:05:02 PM
STTIME = 3:01:02 PM
Running a simple select statement subtracting the two fields with the above
times returns a value of 0.29444444444.

HERE IS THE QUERY:

SELECT Sum(AHRET) AS MonChgRtn, Count(VehicleID ) AS ChgCount, Min(STSOC) AS
MinSTSOC,
Max(NDT) AS MaxNDT, Max(STT) as MaxSTT,
IIf(MaxNDT>MaxS TT,MaxNDT,MaxST T) AS MaxTemp,
IIf([CT]="FC","Yes","No ") AS FullChg,
IIf([CT]="EQ" AND ([NDTIME]-[STTIME])>5,"Yes","No" ) AS EQChg, CT
FROM ChargeLog_longt ime
WHERE (((STDATE)=#10/6/2003#) AND ((VehicleID)=10 101010))
GROUP BY IIf([CT]="FC","Yes","No "), IIf([CT]="EQ" AND
([NDTIME]-[STTIME])>(format(5,"tt tt")),"Yes","No "), CT;

Thanks,
mark

Nov 12 '05 #1
1 9203
Take a look at the DateDiff built-in function. Get the result in seconds and
break that result down into hours, minutes, and seconds (the integer divide
\ and Mod operators will come in handy).

Larry Linson
Microsoft Access MVP

"mark" <ms@nospam.comc ast.net> wrote in message
news:72******** ************@co mcast.com...
I'm stuck:
In a query I am trying to compare two fields with a date/time data type and a LongTime format to get the difference in hours (minutes and seconds if
possible). After that I need to determine if the difference is greater than 5 hours.
The part of the query looks like this so far (IIf([CT]="EQ" AND
([NDTIME]-[STTIME])>5,"Yes","No" ) AS EQChg) but doesn't come out right.
NDTIME = 10:05:02 PM
STTIME = 3:01:02 PM
Running a simple select statement subtracting the two fields with the above times returns a value of 0.29444444444.

HERE IS THE QUERY:

SELECT Sum(AHRET) AS MonChgRtn, Count(VehicleID ) AS ChgCount, Min(STSOC) AS MinSTSOC,
Max(NDT) AS MaxNDT, Max(STT) as MaxSTT,
IIf(MaxNDT>MaxS TT,MaxNDT,MaxST T) AS MaxTemp,
IIf([CT]="FC","Yes","No ") AS FullChg,
IIf([CT]="EQ" AND ([NDTIME]-[STTIME])>5,"Yes","No" ) AS EQChg, CT
FROM ChargeLog_longt ime
WHERE (((STDATE)=#10/6/2003#) AND ((VehicleID)=10 101010))
GROUP BY IIf([CT]="FC","Yes","No "), IIf([CT]="EQ" AND
([NDTIME]-[STTIME])>(format(5,"tt tt")),"Yes","No "), CT;

Thanks,
mark

Nov 12 '05 #2

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

Similar topics

2
2118
by: Jan Szymczuk | last post by:
I am trying to create a query that will show me who is phoning who in an organisation from available Telephone Billing information. I am creating a MSAccess 2000 database with a few few tables, two of which are: TableMembers: (containg fields Refs, DateCreated, MembershipNo, OfficeLocation ...NB: Refs has a Primary Key - No Duplicates) TablePeople: (containing fields: Refs, Name, Addr, TelHome, TelWork, TelMobile & TelFax)...
6
5263
by: AAVF | last post by:
Hi We have a problem with a query. An Access database links via ODBC to a UNIX server. To speed things, we use the ODBC to load the relevant tables to the local PC that runs Access so that all querying is done locally. One of the reports we run allows the user to list all invoices within a period. They are also allowed to select a customer code and a product set on
6
3375
by: Tony Williams | last post by:
SORRY I know we shouldn't do this but I'm desperate for an answer to this and the previous post didn't seem to get a response. I have a table with two fields, txtvalue (a number field) and txtmonth ( a date/time field). I want to create a report that shows the difference in value between the value in txtvalue in one value of txtmonth and the value of txtvalue in another value of txtmonth and the percentage increase . For example if I...
6
2814
by: Mark | last post by:
Hello. I have an MS Access 2000 form whose fields I need to read and write from VBA. The fields are data-bound, using a query that has been defined and saved in my Access database. The query uses local data only (no external references.) This worked fine until I added some additional fields to the recordset. The new fields do not show up in the object browser, and I get an error if I try to use them. This problem occurs whether
9
5751
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just call it Express for simplicity). I have, to try to simplify things, put the exact same DB on two systems, one running MSDE and one running Express. Both have 2 Ghz processors (one Intel, one AMD), both have a decent amount of RAM (Intel system...
2
4858
by: Luke.Schollmeyer | last post by:
I found an unusual problem between 2000 and 2005 I haven't been able to decipher from any documentation. The query structure is as follows: select * from tableA a join tableB b ON a.somekey = b.somekey
10
2356
Dököll
by: Dököll | last post by:
Hey Guys! I ran into a puzzle; below query gets me what I need (Difference from two time fields) in Ms Access 2000 but not in MS Access 2003, any idea why: SELECT Data.ID, Data.GetTextFromText, Data.Stamp, DateDiff("h",,) AS HoursFromTimes FROM Data; Thanks for your help!
5
1455
by: bobh | last post by:
Hi All, Is there a difference in preformance between the two; TblNme has 36 fields across a record a query that selects all fields and the report only uses 75% of the fields, ie; Select TblNme.* where OffCde='123' or
4
3854
by: Quizzed | last post by:
Hi, Using MS Access 97, i have a query over an As/400 which returns a number of fields. Within each record returned, two fields are of numeric data type but contain values relating to time. The first field contains the start time, the second field contains the finish time. Within my query, I need to calculate the the difference bewteen the two in order to ascertain the duration. Finish Time minus Start Time dosent work as the value isnt...
0
8380
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8296
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
8816
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
8710
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8497
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7310
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...
1
6162
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5627
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();...
2
1598
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.