473,486 Members | 2,131 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

barkarlo

59 New Member
what do I have to do,so the function returns the correct result when the end of the worktime passes midnight?
Public Function HoursAndMinutes(interval as variant) as string
dim totalminutes as long, totalseconds as long
dim hours as long, minutes as long, seconds as long
if isnull(interval)= true then exit function
hours = Int(CSng(interval*24))
totalminutes = Int(CSng(interval*1440))
minutes = totalminutes mod 60
totalseconds =Int(CSng(interval*86400))
seconds = totalseconds mod 60

if seconds>30 then minutes = minutes+1
if minutes>59 then hours = hours+1:minutes=0
HoursAndMinutes = hours & ":" & format(minutes, "00")
End function

for an example starttime endtime function return totalwork
22:30 02:30 -20:00
I want to see 04:00

Thanks for help
Nov 7 '06 #1
1 898
Killer42
8,435 Recognized Expert Expert
One fairly simple approach is just to add a day if the end time is earlier than the start time. Like...
Total = End - Start - 86400 * (Start > End)
This is just a rough version straight off the top of my head. (It works on the assumptions that True equates to -1, and you are working in seconds).
Nov 7 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

13
1509
by: barkarlo | last post by:
I need help to create a function that will return total worktime for each employee who works sundays. I have the folloving simple table ID Employee Datum Starttime ...
17
11190
by: barkarlo | last post by:
I need help to make grand total time in continuous forms. to calculate total work time I use following formula =format(+1--nz();"short time"). but when I make grand total time in form footer (for...
19
3195
by: kds14589 | last post by:
I'm new to acess and working on my first db. I haven't started using code yet so i still working with wizards. I am using Acess 2000 on an Windows XP. My problem is i have a time field that i need...
32
3387
by: barkarlo | last post by:
In my table date/time field (starttime,endtime) include both date and time. How can I calculate worktime in query for each employee who works sundays? for an example: sometimes starttime and...
3
2596
by: barkarlo | last post by:
how can I create input mask for invoice number for an example 07-08000-427 where 07-08000 is constant and 427 is changes. I would like write only number who is changes.
2
2022
by: barkarlo | last post by:
I have two controls with numbers. when I want divide them in some cases my result is #Div/0!. for an example: control1 control2 1000 0 formula is: control1/control2 result is #div/0!...
3
2356
by: barkarlo | last post by:
how can I calculated days between e.g. 08/05/2007 and last day in that month.
5
2478
by: barkarlo | last post by:
I must divide income from 2007 and 2006. but in same cases income in 2006 is null and result is #error. How can I see 0 for this case. for an example 120/0=0
1
1090
by: barkarlo | last post by:
I'm trying send to e-mail the current record from my report but each time all record send. Can I send only one record from a report.
4
4375
by: barkarlo | last post by:
I use check box in a form "frmworkorder" like confirmation that's record finish. How can I write code who will block edit and delete record in form when is check box confirmed.
0
7100
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,...
0
6964
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...
0
7126
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,...
0
7175
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...
0
5434
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,...
0
4559
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...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
262
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...

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.