If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Calculating elapsed time
I am trying to calculate the elapsed time between between two time periods.
The begin time in the afternoon (PM) of one day and the end time is the morning (AM)of the following day. Example =HoursAndMinutes([TimeOut]-[TimeIn]) When I use the expression above for the time period Jan1, 2005 Begin Time 10:00 PM and End Time 2:00 AM (the following day) returns the answer "-20" Please help Wallace |
#2
|
|||
|
|||
Calculating elapsed time
On Wed, 19 Oct 2005 18:34:02 -0700, WKN
wrote: I am trying to calculate the elapsed time between between two time periods. The begin time in the afternoon (PM) of one day and the end time is the morning (AM)of the following day. Example =HoursAndMinutes([TimeOut]-[TimeIn]) When I use the expression above for the time period Jan1, 2005 Begin Time 10:00 PM and End Time 2:00 AM (the following day) returns the answer "-20" Please help Wallace The DateDiff() function returns the difference between two date/time values, correctly handling over midnight (or over many days, in fact); you can get the time difference in any unit from seconds to years (as an integer, not a Date/Time). DateDiff("n", [TimeIn], [TimeOut]) will return the number of minutes; to display as hh:nn you can use DateDiff("n", [TimeIn], [TimeOut]) \ 60 & ":" & Format(DateDiff("n", [TimeIn], [TimeOut]) MOD 60, "00") John W. Vinson[MVP] |
#3
|
|||
|
|||
Calculating elapsed time
Thanks for the assistance.
I tried the DateDiff() function. I got an answer of -20 (the correct answer would be 4). Where am I going wrong? Wallace "WKN" wrote: I am trying to calculate the elapsed time between between two time periods. The begin time in the afternoon (PM) of one day and the end time is the morning (AM)of the following day. Example =HoursAndMinutes([TimeOut]-[TimeIn]) When I use the expression above for the time period Jan1, 2005 Begin Time 10:00 PM and End Time 2:00 AM (the following day) returns the answer "-20" Please help Wallace |
#4
|
|||
|
|||
Calculating elapsed time
Sounds like you have the dates switched in the datediff() function
the answer you are getting is ( Jan 2, 2005 2:00am to Jan1, 2005 10pm ) = -20 hours. what you want is DateDiff("h", EarlyDate, LateDate) Ed Warren. "WKN" wrote in message ... Thanks for the assistance. I tried the DateDiff() function. I got an answer of -20 (the correct answer would be 4). Where am I going wrong? Wallace "WKN" wrote: I am trying to calculate the elapsed time between between two time periods. The begin time in the afternoon (PM) of one day and the end time is the morning (AM)of the following day. Example =HoursAndMinutes([TimeOut]-[TimeIn]) When I use the expression above for the time period Jan1, 2005 Begin Time 10:00 PM and End Time 2:00 AM (the following day) returns the answer "-20" Please help Wallace |
#5
|
|||
|
|||
Calculating elapsed time
I am still getting the wrong answer (-20). I should point out that the table
I am using has the following fields: Employee, Date, Time In, Time Out, Hrs/Mnts Worked. Thanks Wallace "Ed Warren" wrote: Sounds like you have the dates switched in the datediff() function the answer you are getting is ( Jan 2, 2005 2:00am to Jan1, 2005 10pm ) = -20 hours. what you want is DateDiff("h", EarlyDate, LateDate) Ed Warren. "WKN" wrote in message ... Thanks for the assistance. I tried the DateDiff() function. I got an answer of -20 (the correct answer would be 4). Where am I going wrong? Wallace "WKN" wrote: I am trying to calculate the elapsed time between between two time periods. The begin time in the afternoon (PM) of one day and the end time is the morning (AM)of the following day. Example =HoursAndMinutes([TimeOut]-[TimeIn]) When I use the expression above for the time period Jan1, 2005 Begin Time 10:00 PM and End Time 2:00 AM (the following day) returns the answer "-20" Please help Wallace |
#6
|
|||
|
|||
Calculating elapsed time
Check the Date for the TimeIn and TimeOut Fields. Sounds Like they do not
have the proper date and you are calculating the time from 0200--1000 You don't need to store the Hrs/mins worked. That is a calculated field. You also don't need to have a 'date' field. You need: Employee TimeIn, TimeOut (TimeIn and TimeOut should include both the date and time, if they do then your calculations will be correct). Eg. TimeIn (1/1/2005 10:00 pm) TimeOut (1/2/2005 02:00 am) Ed Warren "WKN" wrote in message ... I am still getting the wrong answer (-20). I should point out that the table I am using has the following fields: Employee, Date, Time In, Time Out, Hrs/Mnts Worked. Thanks Wallace "Ed Warren" wrote: Sounds like you have the dates switched in the datediff() function the answer you are getting is ( Jan 2, 2005 2:00am to Jan1, 2005 10pm ) = -20 hours. what you want is DateDiff("h", EarlyDate, LateDate) Ed Warren. "WKN" wrote in message ... Thanks for the assistance. I tried the DateDiff() function. I got an answer of -20 (the correct answer would be 4). Where am I going wrong? Wallace "WKN" wrote: I am trying to calculate the elapsed time between between two time periods. The begin time in the afternoon (PM) of one day and the end time is the morning (AM)of the following day. Example =HoursAndMinutes([TimeOut]-[TimeIn]) When I use the expression above for the time period Jan1, 2005 Begin Time 10:00 PM and End Time 2:00 AM (the following day) returns the answer "-20" Please help Wallace |
#7
|
|||
|
|||
Calculating elapsed time
Access doesn't have a Time data type: all it has is the Date data type,
which is intended to include both date and time (internally, it's stored as an 8 byte floating point number, where the integer portion represents the date as the number of days relative to 30 Dec, 1899, and the decimal portion represents the time as a fraction of a day) You can solve the problem by storing the date along with the time (you can use the DateValue or TimeValue functions to extract just the date or just the time should you need it elsewhere). You could also take a look at http://www.mvps.org/access/datetime/date0008.htm at "The Access Web" (although I feel it's a mistake to only store time without date...) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "WKN" wrote in message ... I am still getting the wrong answer (-20). I should point out that the table I am using has the following fields: Employee, Date, Time In, Time Out, Hrs/Mnts Worked. Thanks Wallace "Ed Warren" wrote: Sounds like you have the dates switched in the datediff() function the answer you are getting is ( Jan 2, 2005 2:00am to Jan1, 2005 10pm ) = -20 hours. what you want is DateDiff("h", EarlyDate, LateDate) Ed Warren. "WKN" wrote in message ... Thanks for the assistance. I tried the DateDiff() function. I got an answer of -20 (the correct answer would be 4). Where am I going wrong? Wallace "WKN" wrote: I am trying to calculate the elapsed time between between two time periods. The begin time in the afternoon (PM) of one day and the end time is the morning (AM)of the following day. Example =HoursAndMinutes([TimeOut]-[TimeIn]) When I use the expression above for the time period Jan1, 2005 Begin Time 10:00 PM and End Time 2:00 AM (the following day) returns the answer "-20" Please help Wallace |
#8
|
|||
|
|||
Calculating elapsed time
Hey. Thank you all very much. I see where I was going wrong.
Thanks again Wallace "Douglas J Steele" wrote: Access doesn't have a Time data type: all it has is the Date data type, which is intended to include both date and time (internally, it's stored as an 8 byte floating point number, where the integer portion represents the date as the number of days relative to 30 Dec, 1899, and the decimal portion represents the time as a fraction of a day) You can solve the problem by storing the date along with the time (you can use the DateValue or TimeValue functions to extract just the date or just the time should you need it elsewhere). You could also take a look at http://www.mvps.org/access/datetime/date0008.htm at "The Access Web" (although I feel it's a mistake to only store time without date...) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "WKN" wrote in message ... I am still getting the wrong answer (-20). I should point out that the table I am using has the following fields: Employee, Date, Time In, Time Out, Hrs/Mnts Worked. Thanks Wallace "Ed Warren" wrote: Sounds like you have the dates switched in the datediff() function the answer you are getting is ( Jan 2, 2005 2:00am to Jan1, 2005 10pm ) = -20 hours. what you want is DateDiff("h", EarlyDate, LateDate) Ed Warren. "WKN" wrote in message ... Thanks for the assistance. I tried the DateDiff() function. I got an answer of -20 (the correct answer would be 4). Where am I going wrong? Wallace "WKN" wrote: I am trying to calculate the elapsed time between between two time periods. The begin time in the afternoon (PM) of one day and the end time is the morning (AM)of the following day. Example =HoursAndMinutes([TimeOut]-[TimeIn]) When I use the expression above for the time period Jan1, 2005 Begin Time 10:00 PM and End Time 2:00 AM (the following day) returns the answer "-20" Please help Wallace |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Time Zone suggestions for Outlook Calendar | Ben Knox | Calendar | 2 | October 20th, 2005 03:42 PM |
Display elapsed time greater than 24 hours | mikelee101 | New Users | 2 | July 1st, 2005 12:04 AM |
Calculating a rate for elapsed time? | Keith | General Discussion | 8 | May 18th, 2005 09:14 PM |
Calculating time on a time card | Kevin | General Discussion | 1 | January 10th, 2005 06:23 AM |
Calculating (Date and Time) differences | Frank Kabel | Worksheet Functions | 2 | April 27th, 2004 11:19 PM |