English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

So far I have a design like this...

http://img169.imageshack.us/img169/4538/image1ew4.jpg

Simple, so that the user can input hours the employee started, and finished work. Good thing is, this has nothing to do with wages, just hours.

The only thing is, I can't figure out how to make it go past the 12 hour. Meaning if someone worked from 7AM to 4PM, what code would I enter for it to calculate that, with the lunch hour taken (minus an hour), also the digit part, as 12 changes to 1.

I understand from 7-12, since I would just make it increase 5, but once it changes over to 1, my numbers get all messed up. I also understand that after a time is entered for "In-Time" and "Out-Time" for a day, a new value must be created with those hours added up, even though it won't be displayed. And from there, I would take those newly created values, and add them up for the "Total Hrs.". I'm trying to do this for my boss who has trouble with computers big time.

If you can help, thank you so much! =)

2007-03-17 11:12:05 · 5 answers · asked by alphaaxl 1 in Computers & Internet Programming & Design

So sorry, I meant to include it in my description. I'm using Visual Basic 2005 Express, doing VB coding.

2007-03-17 11:27:31 · update #1

Also, not all employees are full timers and don't all have lunches. Would I have to do IF and THEN statements then?

Something like IF $hoursworked is greater than 8, THEN minus 1? Something like that I know, thank you all for trying to help.

2007-03-17 11:30:00 · update #2

5 answers

If you are using VB, then you should look into the datediff function:

if you do a 12 hour clock you can do like this:
datediff("h", "08:00:00 AM", "05:00:00 PM")
= 9

Also you could use a 24 hour clock this:
datediff("h", "08:00", "13:00")
= 5

You will need to validate what the user inputs, but I think this should be the easiest way...

HTH

2007-03-17 11:54:33 · answer #1 · answered by Dilbert 3 · 0 0

dude you have not said anything about the language or anything.

I am thinking that you are doing asp.net.

anyway this is how i would do it.

first and the most easier way to do it is to use a 24 hour clock.

Now if you just want a 12 hour clock then you gonna have to use another box to identify its am or pm. so when you have both am hour then you would chose one way to find time and if it is am and pm then its another.

so here it goes.

if (both are am){ total hour for one day = start hour - finish hour}
if (one is pm){ total hour for one day =24 - start hour + finish hour }

and then you can do the hour subtraction of lunch from the total hour for one day.

its not exact code but if you are even beginner, you will find a way to do this in 5 minutes.

2007-03-17 18:36:59 · answer #2 · answered by sobank 2 · 0 0

You'd need to code a form to send the variable, but if they're constants

$timein = 7.00;
$timeout = 17:30;
$lunch = 1;

$hoursworked = $timeout - $timein;
$hoursworked = $hoursworked - $lunch;

echo "You've worked " $hoursworked " hours";

?>

2007-03-17 18:22:30 · answer #3 · answered by Slappy 3 · 0 0

Mike is 100 % correct.

I don't even know what application you are using let alone which language to program the coding / formula in.

Thank you for trying to give as much detail as possible but no one can answer this question.

2007-03-17 18:20:37 · answer #4 · answered by Chεεrs [uk] 7 · 0 0

What language are you using? Some sample code might help also so we can see what you are doing.

2007-03-17 18:16:39 · answer #5 · answered by mikehome.com 1 · 0 0

fedest.com, questions and answers