Hello,
I have a access query that reads in 2 time fields but its not in time format. Example: 900, 1300, 256, 2245, etc. What I am trying to do is driver comes in at 900(9:00AM) and leaves at 1300(1:00PM). Then have it give me the total time he was here, 4 hours
The build expression is as follows:
Total Time:
IIf([CARRIER_OFF_DOCK_TIME]>959,TimeSerial(Mid([CARRIER_OFF_DOCK_TIME],1,2),Mid([CARRIER_OFF_DOCK
_TIME],3,2),0),TimeSerial(Mid([CARRIER_OFF_DOCK_TIME],1,1),Mid([CARRIER_OFF_DOCK_TIME],2,2),0)) - IIf([CARRIER_ON_DOCK_TIME]>959,TimeSerial(Mid([CARRIER_ON_DOCK_TIME],1,2),Mid([CARRIER_ON_DOCK
_TIME],3,2),0),TimeSerial(Mid([CARRIER_ON_DOCK_TIME],1,1),Mid([CARRIER_ON_DOCK_TIME],2,2),0))
That should work but I get an error: "Data type mismatch in criteria expression."
The last thing I should mention is that I have no control over the time being read into the query. Its link to a table outside of Access.
Any insight would be great.
Thx,
John
4 10900
Hi, John.
Try the following to convert [CARRIER_ON_DOCK_TIME] to time: -
TimeSerial([CARRIER_ON_DOCK_TIME]/100, [CARRIER_ON_DOCK_TIME] mod 100, 0)
-
Note that subtracting one date from another gives by default difference in days. To convert it to hours you may use Format() function -
Format (TimeSerial([CARRIER_OFF_DOCK_TIME]/100, [CARRIER_OFF_DOCK_TIME] mod 100, 0) - TimeSerial([CARRIER_ON_DOCK_TIME]/100, [CARRIER_ON_DOCK_TIME] mod 100, 0), "h")
-
or -
Format (TimeSerial([CARRIER_OFF_DOCK_TIME]/100, [CARRIER_OFF_DOCK_TIME] mod 100, 0) - TimeSerial([CARRIER_ON_DOCK_TIME]/100, [CARRIER_ON_DOCK_TIME] mod 100, 0), "hh:mm")
-
to get hours and minutes
or simply multiply the result on 24 -
(TimeSerial([CARRIER_OFF_DOCK_TIME]/100, [CARRIER_OFF_DOCK_TIME] mod 100, 0) - TimeSerial([CARRIER_ON_DOCK_TIME]/100, [CARRIER_ON_DOCK_TIME] mod 100, 0))*24
-
Regards,
Fish
Thanks Fish,
I will give it a try and post back.
-John
Thanks Fish, its work but I have to work with it alittle. Some of the values for the Total Time are incorrect but most are right. -
Format (TimeSerial([CARRIER_OFF_DOCK_TIME]/100, [CARRIER_OFF_DOCK_TIME] mod 100, 0) - TimeSerial([CARRIER_ON_DOCK_TIME]/100, [CARRIER_ON_DOCK_TIME] mod 100, 0), "hh:mm")
-
Example:
1537 - 1658 = 02:21 is incorrect
2213 - 59 = 20:14 is incorrect
1411 - 1646 = 2:35 correct
601 - 1033 = 4:32 correct
So I may have to use conditional statements for when the time rolls into a new day too. If you have any ideas that would be great.
Thx,
John
Hi, John.
The following code will work correctly. -
Format (TimeSerial(int([CARRIER_OFF_DOCK_TIME]/100), [CARRIER_OFF_DOCK_TIME] mod 100, 0) - TimeSerial(int([CARRIER_ON_DOCK_TIME]/100), [CARRIER_ON_DOCK_TIME] mod 100, 0), "hh:mm")
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Nikola |
last post by:
Hi all,
I have a problem converting datetime to integer (and than back to
datetime).
Depending whether the time is AM or PM, same date is converted to two
different integer representations,...
|
by: renee_ld |
last post by:
In a query I used the function datediff to calculate the number of
minutes between two time periods on a given day. This function returned
the number of minutes as a long integer data type. I...
|
by: zexpe |
last post by:
I have an extremely cpu/data intensive piece of code that makes heavy
use of the following function:
void convertToDouble(const std::string& in, double& out)
{
out = atof(in.c_str());
}
I...
|
by: NateM |
last post by:
How do I convert any given date into a milliseconds value that
represents the number of milliseconds that have passed since January 1,
1970 00:00:00.000 GMT?
Is there an easy way to do this like...
|
by: Rico |
last post by:
Hello,
I have an application that I'm converting to Access 2003 and SQL Server 2005
Express. The application uses extensive use of DAO and the SEEK method on
indexes. I'm having an issue when...
|
by: Tor Aadnevik |
last post by:
Hi,
I have a problem converting values from Single to double.
eg. When the Single value 12.19 is converted to double, the result is
12.1899995803833.
Anyone know how to avoid this?
Regards...
|
by: Chris Asaipillai |
last post by:
Hi there
My compay has a number of Visual Basic 6 applications which are front endeed onto
either SQL Server or Microsoft Access databases.
Now we are in process of planning to re-write these...
|
by: Randy Reimers |
last post by:
(Hope I'm posting this correctly, otherwise - sorry!, don't know what else
to do)
I wrote a set of programs "many" years ago, running in a type of basic,
called "Thoroughbred Basic", a type of...
|
by: Jef Driesen |
last post by:
How can I convert a date string to a number (e.g. a time_t value or a tm
struct)? I know about the strptime function, but then I have to know the
format string. And that is a problem.
I'm trying...
|
by: Dirk Hagemann |
last post by:
Hello,
From a zone-file of a Microsoft Active Directory integrated DNS server
I get the date/time of the dynamic update entries in a format, which
is as far as I know the hours since january 1st...
|
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...
|
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...
|
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,...
|
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...
| |