A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Total working hours problem if it start from 30 at night and ends onthe 31 morning



 
 
Thread Tools Display Modes
  #1  
Old November 14th, 2009, 08:18 AM posted to microsoft.public.access.forms
Tia[_3_]
external usenet poster
 
Posts: 126
Default Total working hours problem if it start from 30 at night and ends onthe 31 morning

Dear all, i am using this to get the total wroking hours per day
TOTAL WORKING HOURS PER DAY: DateDiff("n",[TIME IN],[TIME OUT]+DateDiff
("n",[TIME IN 2],[TIME OUT 2]))/60

It is working perfectly until i have this
Employee Name Day Date Time Clock
In/OUT
Tia Kareem Fri 10/30/2009 5:59pm IN
Tia Kareem Sat 10/31/2009 3:27am OUT

IF i will use the same expression i will be getting total working
hours per day : -14.53
Employee Name Date IN
OUT Total Working Hours
Tia Kareem 10/30/2009 5:59pm
3:27am -14.53
Jason 10/30/2009 9:00 am
18:00pm 9

How can i get the total of 09:47 per day if they worked from 30 till
31 in one shift?

Best Regards
  #2  
Old November 14th, 2009, 11:56 AM posted to microsoft.public.access.forms
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Total working hours problem if it start from 30 at night and ends on the 31 morning

The problem is that you're strictly using Time In and Time Out. You really
should have Date/Time In and Date/Time Out.

For the meantime, take a look at
http://www.mvps.org/access/datetime/date0008.htm at "The Access Web"

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Tia" wrote in message
...
Dear all, i am using this to get the total wroking hours per day
TOTAL WORKING HOURS PER DAY: DateDiff("n",[TIME IN],[TIME OUT]+DateDiff
("n",[TIME IN 2],[TIME OUT 2]))/60

It is working perfectly until i have this
Employee Name Day Date Time Clock
In/OUT
Tia Kareem Fri 10/30/2009 5:59pm IN
Tia Kareem Sat 10/31/2009 3:27am OUT

IF i will use the same expression i will be getting total working
hours per day : -14.53
Employee Name Date IN
OUT Total Working Hours
Tia Kareem 10/30/2009 5:59pm
3:27am -14.53
Jason 10/30/2009 9:00 am
18:00pm 9

How can i get the total of 09:47 per day if they worked from 30 till
31 in one shift?

Best Regards



  #3  
Old November 14th, 2009, 06:59 PM posted to microsoft.public.access.forms
Joe[_2_]
external usenet poster
 
Posts: 17
Default Total working hours problem if it start from 30 at night and ends on the 31 morning

Try This:

Dim sngTotal As Single
Dim sngDailySum As Single

sngTotal = DateDiff("n", [txtIn], [txtOut]) / 60 'Calculate the minutes
and divide by 60

If Sgn(sngTotal) = -1 Then 'If the number is negative
txtOut = DateAdd("d", 1, txtOut) 'add one day
sngTotal = DateDiff("n", [txtIn], [txtOut]) / 60
End If

HTH


"Tia" wrote in message
...
Dear all, i am using this to get the total wroking hours per day
TOTAL WORKING HOURS PER DAY: DateDiff("n",[TIME IN],[TIME OUT]+DateDiff
("n",[TIME IN 2],[TIME OUT 2]))/60

It is working perfectly until i have this
Employee Name Day Date Time Clock
In/OUT
Tia Kareem Fri 10/30/2009 5:59pm IN
Tia Kareem Sat 10/31/2009 3:27am OUT

IF i will use the same expression i will be getting total working
hours per day : -14.53
Employee Name Date IN
OUT Total Working Hours
Tia Kareem 10/30/2009 5:59pm
3:27am -14.53
Jason 10/30/2009 9:00 am
18:00pm 9

How can i get the total of 09:47 per day if they worked from 30 till
31 in one shift?

Best Regards



  #4  
Old November 15th, 2009, 01:07 PM posted to microsoft.public.access.forms
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default Total working hours problem if it start from 30 at night and ends on the 31 morning

Or this:

If StartTime StopTime Then
LapsedHours = (DateDiff("n",StartTime,StopTime) + 1440)/60
Else
LapsedHours = DateDiff("n",StartTime,StopTime)/60
End If

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200911/1

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:55 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.