|
-
Dec 16th, 2000, 06:30 PM
#1
Thread Starter
New Member
I am creating a daily payroll program that allows an employ to come in and out 6 times a day. When I Add up the hours the employee came and went out it does not compute correctly.
Example: In at 8am - Out at 10am = 2 hrs worked. The program is totallying up the hours to give me 18hrs. How and what do i need to do to get the correct hours to reflect. Any suggestions would be helpful.
Thanks
-
Dec 16th, 2000, 06:39 PM
#2
-
Dec 16th, 2000, 07:29 PM
#3
Thread Starter
New Member
Originally posted by Matthew Gates
Use the Val Function.
Thank you for your reply;
I am using the Val funtction. Actually I think I found the answer but I am not all the way there. My code actually looks like this:
Dim In1 as SINGLE
Dim Out1 as Single
In1 = Val(txtIn1.Text)
Out1 = Val(txtout1.Text)
pictotal1.Print In1 - Out1
I had the last function adding the two so that is why I was getting the big numbers. I just put in the minus function but I can't get my program to display the if I put in the colon( to display hours. Any more sugestions?
Thanks
-
Dec 16th, 2000, 07:49 PM
#4
Addicted Member
In1 - Out1???
I know I'm not Einstien, but shouldn't it be Out1 - In1? Like, the time at which the person left, minus the time he got in?
-
Dec 16th, 2000, 11:03 PM
#5
Thread Starter
New Member
Originally posted by Arcom
In1 - Out1???
I know I'm not Einstien, but shouldn't it be Out1 - In1? Like, the time at which the person left, minus the time he got in?
Thank You!
We are geting closer. It gives me the correct time now but I am still not able to put in a number with a colon (8:00) and get the correct out put. It does not give me the correct hours if I enter 8 from 10:15 such as( i.e.,1.34).
Any more suggestions asnyone?
-
Dec 17th, 2000, 06:31 AM
#6
Haven't any of you guys heard of the DATEDIFF function?
Designed specifically for your problem.
Code:
Hours_Worked = datediff("h", in1, out1)
-
Dec 17th, 2000, 10:14 AM
#7
PowerPoster
Well, wossname method is good, but it may also calculate incorrectly. Because may not all employee will check in/out sharp at 8am or 10am rite.
So, it will be more accurate is you get the time dufferent between the check in/out time in second, then only start your payroll algorithm.
Code:
Hours_Worked = datediff("s", in1, out1)
-
Dec 17th, 2000, 12:01 PM
#8
Thread Starter
New Member
Originally posted by Chris
Well, wossname method is good, but it may also calculate incorrectly. Because may not all employee will check in/out sharp at 8am or 10am rite.
So, it will be more accurate is you get the time dufferent between the check in/out time in second, then only start your payroll algorithm.
Code:
Hours_Worked = datediff("s", in1, out1)
Thank You all for your response.
I will give it a try.
-
Dec 17th, 2000, 12:06 PM
#9
Chris, I was hoping lunar could work that out for him/herself I didn't intend it to be a perfect solution 
Anyway why not use minutes instead of seconds, (most companies round down to the nearest couple of minutes anyway)? The code for which is "n" when using datediff.
-
Dec 17th, 2000, 05:42 PM
#10
Thread Starter
New Member
Originally posted by wossname
Chris, I was hoping lunar could work that out for him/herself I didn't intend it to be a perfect solution 
Anyway why not use minutes instead of seconds, (most companies round down to the nearest couple of minutes anyway)? The code for which is "n" when using datediff.
Again, thanks for the responses and I was intending on using minutes. I saw that DateDiff function on a couple of example I found while doing my research on this problem. Unfortunately, I am new to this and the book that was required for this class does not mention that function. What's even worse is that this project is assigned and that function would be essential.
Again Thanks,
-
Dec 17th, 2000, 08:12 PM
#11
PowerPoster
Lunar1, perhaps the following url can be the reference point for your in your assignment or your future prospect:
[*]Planet Source Code[*]MSDN Online Library[*]VB XML[*]CodeGuru
above juz some of my bookmark and hope it can make sense to you.
Chris
-
Dec 17th, 2000, 11:38 PM
#12
Thread Starter
New Member
Originally posted by Chris
Lunar1, perhaps the following url can be the reference point for your in your assignment or your future prospect:
[*]Planet Source Code[*]MSDN Online Library[*]VB XML[*]CodeGuru
above juz some of my bookmark and hope it can make sense to you.
Chris
Thanks to all of you who responded. I got it figured out.
-
Dec 18th, 2000, 01:14 PM
#13
Lunar1: Hi, don't wish to be rude, but could you possibly quote people less frequently, its a bit confusing when searching for a specific posting in a long thread.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|