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

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>MaxSTT,MaxNDT,MaxSTT) AS MaxTemp,
IIf([CT]="FC","Yes","No") AS FullChg,
IIf([CT]="EQ" AND ([NDTIME]-[STTIME])>5,"Yes","No") AS EQChg, CT
FROM ChargeLog_longtime
WHERE (((STDATE)=#10/6/2003#) AND ((VehicleID)=10101010))
GROUP BY IIf([CT]="FC","Yes","No"), IIf([CT]="EQ" AND
([NDTIME]-[STTIME])>(format(5,"tttt")),"Yes","No"), CT;

Thanks,
mark

Nov 12 '05 #1
1 9184
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.comcast.net> wrote in message
news:72********************@comcast.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>MaxSTT,MaxNDT,MaxSTT) AS MaxTemp,
IIf([CT]="FC","Yes","No") AS FullChg,
IIf([CT]="EQ" AND ([NDTIME]-[STTIME])>5,"Yes","No") AS EQChg, CT
FROM ChargeLog_longtime
WHERE (((STDATE)=#10/6/2003#) AND ((VehicleID)=10101010))
GROUP BY IIf([CT]="FC","Yes","No"), IIf([CT]="EQ" AND
([NDTIME]-[STTIME])>(format(5,"tttt")),"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
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...
6
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...
6
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...
6
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...
9
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...
2
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...
10
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,...
5
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...
4
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
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...
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...

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.