Jump to content

Recommended Posts

Posted

I'm a bit weak in terms of calculation :( Can you give me an example of how to calculate the hourly rate. For example: from 18:00 to 19:00 is 1 hour. Here 1 hour = 1000 money. Counting from the start time to the end time is how many minutes and calculating the money, the better.

Posted (edited)
8 hours ago, Loc said:

I'm a bit weak in terms of calculation :( Can you give me an example of how to calculate the hourly rate.

:huh::no:

I assume that you meant how to calculate the gross wages since you said "1 hour = 1000 money".

  1. Use _DateDiff to calculate the number of minutes between start and end times
  2. Divide minutes by 60 to get hours
  3. Multiply hours times hourly rate to calculate gross wages

 

#include <Constants.au3>
#include <Date.au3>

Const  $HOURLY_RATE = 1000.00, _
       $START_TIME  = '2020-10-18 23:00', _
       $END_TIME    = '2020-10-19 06:30'

Global $fHours = _DateDiff('n', $START_TIME, $END_TIME) / 60
Global $fWages = $fHours * $HOURLY_RATE

MsgBox($MB_ICONINFORMATION+$MB_TOPMOST, "Wages", _
       StringFormat("Start = %s\nEnd = %s\n\nHours = %.2f\nRate = %.2f\n\nWages = %.2f", _
                    $START_TIME, $END_TIME, $fHours, $HOURLY_RATE, $fWages))

 

Edited by TheXman
Updated example
Posted (edited)

My intention is to write internet checkout tools. Start timing from what time it will run incrementally up to the current time. I searched and found no one who posted this topic. thanks

Edited by Loc
Posted
16 hours ago, TheXman said:
  1. Use _DateDiff to calculate the number of minutes between start and end times
  2. Divide minutes by 60 to get hours
  3. Multiply hours times hourly rate to calculate gross wages

Agree, although if we’re talking about actual wages paid in the U.S. to physically present employees, you might need a rounding option to the quarter hour, as it is both a legal and still common way of paying people “on the clock”, though less so these days.

Complicating matters somewhat is the fact that rounding usually occurs on both ends of the punch, e.g. 9:08 to 5:07 can be, and often is paid out as 8.75 hours, though of course the opposite can occur.  I remember many a time waiting by the clock for the 8th click before getting an exit punch; though this was obviously frowned upon :)

1B14B971-F14B-4935-8779-F422A737C45B.thumb.png.251ef7e56d9f27472519b9b550136728.png

Code hard, but don’t hard code...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...