What is the formula or condition to count attendance of an employee with "present" value

i dont know how to get the value of present attendance, of a employee, i want to make a salary structure from it, also is there any script to count how many months does our employee already joined?