+ Reply to Thread
Results 1 to 10 of 10

IF Statement Trouble with DATE and TIME - Employee Attendance

Hybrid View

  1. #1
    Registered User
    Join Date
    09-24-2018
    Location
    Texas
    MS-Off Ver
    365
    Posts
    57

    IF Statement Trouble with DATE and TIME - Employee Attendance

    Good Morning,

    Iv attached a spreadsheet that I get when running a time report.. I use this specific time report sheet when calculating employee's "Attendance Points"..

    Time for work is 6:00am to 4:30PM.. I was trying to build a formula that calculated total points that a employee accrued for leaving early or not showing up on time.. I was in the process of building the formula but the cell has a full date and time of when the employee clocked in.. So when I build my IF statements they never compute properly due to the date entry.. Any help would be appreciated..


    Our point schedule is as follows..

    Tardy (< or = 60 minutes of shift) or Leave early (< or = 60 minutes) of remaining shift .25 points

    Tardy (> or = 61 minutes – ½ of scheduled shift) or Leave early (> or = 61 minutes) of shift .5 points

    Absent for more than half of scheduled shift .75 point

    Unexcused absence (call off with 1 hour notice) 1 point

    Unexcused absence (call off with less than 1 hour notice) 1.5 point

    No call/no show 2 points
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: IF Statement Trouble with DATE and TIME - Employee Attendance

    Welcome to the forum.

    The 'full date and time' problem is easy to solve. Dates and times in Excel are just numbers. The dates are whole numbers starting from 1 Jan 1900 which is '1' - today, 24th Sep 18, is 43367. Times are fractions of the day: 0.5 = noon, 0.25 = 6am, etc. Hence the first date/time in your sample, 5:30am on 17th Sep 18, is 43360.2291666667. If you want to work with just the time, then you need to subtract the date part of this - the part before the decimal point - which you do by subtracting the integer.
    So you can get just the time from C2 by using:
    =C2-INT(C2)
    Initially that will show just a number (0.229166667) so format the result as Time to see 5:30am.
    You can then do your calculations based on just the times.

    Hopefully that helps with part of what you need.


    However, I can't see exactly where you want to do the calculations or where you have information about unexcused absences or no-shows? You say the sample is what you get from a timesheet report. How do you know if the absence of any clock-in/out times for a day is because the person wasn't planned to be in or because he/she didn't turn up? I assume this will need to be noted in another column?

    Can you upload an example of roughly what you'd like to have as your final results? Mock them up manually if necessary, showing where you want to have results calculated by formulae. You need to include enough data to show all the variables you expect to encounter (for example, a line showing a tardy, a line showing a leave early, etc, etc) but you don't need hundreds of lines. If some of the data is being imported (clock-in/out for example) but other data is being entered manually, note this so that we can see what is changeable and what isn't.
    Regards,
    Aardigspook

    I recently started a new job so am a bit busy and may not reply quickly. Sorry - it's not personal - I will reply eventually.
    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark this Thread as Solved'.
    If you use commas as your decimal separator (1,23 instead of 1.23) then please replace commas with semi-colons in your formulae.
    You don't need to give me rep if I helped, but a thank-you is nice.

  3. #3
    Registered User
    Join Date
    09-24-2018
    Location
    Texas
    MS-Off Ver
    365
    Posts
    57

    Re: IF Statement Trouble with DATE and TIME - Employee Attendance

    Thanks for the reply,

    I mainly just want a column that tracks tardys.. If the employee doesn't clock at all that's something I can see easily.. Its mainly the tardys, Tardy (< or = 60 minutes of shift) or Leave early (< or = 60 minutes) of remaining shift .25 points or Tardy (> or = 61 minutes – ½ of scheduled shift) or Leave early (> or = 61 minutes) of shift .5 points.

    I made a column for each date range.. I don't need a overall total I just want a simple formula that I can copy into this report and quickly see what the point totals regarding tardys without having to scan each line and notate their points..

  4. #4
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: IF Statement Trouble with DATE and TIME - Employee Attendance

    Try these, in L2 and M2 dragged down, for your Tardy and Leave Early columns:
    Formula: copy to clipboard
    =IF(C2="","",IF(C2-INT(C2)<=6/24,"n/a",IF(C2-INT(C2)>=6/24+1/24,0.5,0.25)))

    Formula: copy to clipboard
    =IF(D2="","",IF(D2-INT(D2)>=16.5/24,"n/a",IF(D2-INT(D2)<=16.5/24-1/24,0.5,0.25)))


    They will return blank if there is no date/time in columns C / D. That's the first part of each formula, in blue.
    If there is a date/time, they will return 'n/a' if the clock-in time is before/at 6am / the clock-out time is at/after 4:30pm. 6am is 6/24, 4:30pm is 16.5/24. That's the second part of each formula, in green.
    If the time is more than/equal to one hour before 6am / after 4:30pm, they will return 0.5. That's the third parts, in red.
    If none of those conditions are met, the only possibility is that the time is within an hour of 6am / 4:30pm, so the result is 0.25. That's the last parts, in black.

    There's one problem with the formulae - they don't account for someone leaving work and coming back on the same day. For example, on rows 144 and 145 of your sample file, the worker clocks-out at 4:31pm then clocks-in again at 4:32pm. The formula generates a 'tardy' of 0.5 for this second clock-in. Similarly on rows 167/168 there are both a 'leave early' 0.5 and 'tardy' 0.5 generated. It would be possible to amend the formula to look for just the first clock-in / last clock-out of each day, but it will make it a bit messier, so do you want that, or are you happy with it like this? If the latter, you could add some Conditional Formatting to highlight when there are two or more clock-ins/outs on one day.


    Does that help?
    Last edited by Aardigspook; 09-25-2018 at 07:41 AM. Reason: Add formula tags

  5. #5
    Registered User
    Join Date
    09-24-2018
    Location
    Texas
    MS-Off Ver
    365
    Posts
    57

    Re: IF Statement Trouble with DATE and TIME - Employee Attendance

    This is amazing.. Thank you - Solved as far as I am concerned!

  6. #6
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: IF Statement Trouble with DATE and TIME - Employee Attendance

    Thank you for the feedback and the rep.

    As you've only recently joined, you may not know that you can mark the thread as Solved if your original question has been taken care of so others know there's an answer here. Instructions to do it are in my sig - if you could take a moment to do it, that would be appreciated. Thanks.

  7. #7
    Registered User
    Join Date
    09-24-2018
    Location
    Texas
    MS-Off Ver
    365
    Posts
    57

    Re: IF Statement Trouble with DATE and TIME - Employee Attendance

    Yes sir will do.. Quick question that just popped up, if a employee clocks in after lunch time, 12:00pm or later the employee gets .75 points.. How do would we add this to the formula to computer the .75 points for a noon + clock in?

  8. #8
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: IF Statement Trouble with DATE and TIME - Employee Attendance

    Quote Originally Posted by jclaborn View Post
    Quick question that just popped up, if a employee clocks in after lunch time, 12:00pm or later the employee gets .75 points.. How do would we add this to the formula to computer the .75 points for a noon + clock in?
    Add another condition, like this (new part shown in red, note the one more bracket at the end too):
    Formula: copy to clipboard
    =IF(C2="","",IF(C2-INT(C2)<=6/24,"n/a",IF(C2-INT(C2)>=12/24,0.75,IF(C2-INT(C2)>=6/24+1/24,0.5,0.25))))

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,518

    Re: IF Statement Trouble with DATE and TIME - Employee Attendance

    It has come to our attention you have violated Rule 8 of our Forum RULES. Don't Private Message, Visitor message or email Excel questions to moderators or other members. (Or Access, Word, etc.)

    All questions and answers will benefit other posters like yourself when discussed in public threads. The point of having a public forum is to share solutions to common (and sometimes uncommon) problems with all members.

    Breaking this rule is considered harassment by most of our contributors and thus cannot be tolerated. Repeat offense could lead to permanent ban, so do take this caution to heart.

    Post your question in a public thread and our many contributors will come to you to assist, especially if the title is accurate (see Rule #1) and you include a sample desensitized workbook that makes it easy for others to try and help.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  10. #10
    Registered User
    Join Date
    09-24-2018
    Location
    Texas
    MS-Off Ver
    365
    Posts
    57

    Re: IF Statement Trouble with DATE and TIME - Employee Attendance

    Understood

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Employee Attendance help please
    By fredek in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-22-2016, 12:06 PM
  2. [SOLVED] Employee Attendance Template
    By mcanny in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-18-2016, 01:07 PM
  3. Creating employee attendance
    By hidetoshi76 in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 12-28-2015, 12:45 PM
  4. Need Help - AutoCalculate Attendance Points for employee attendance records
    By switzd0d in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-17-2015, 03:00 PM
  5. Employee Attendance Record
    By PurpleMe in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-23-2013, 02:15 AM
  6. [SOLVED] High Lighting Current Date In employee Attendance
    By sanjeevi888 in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 07-02-2012, 02:12 PM
  7. employee attendance
    By ruth in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 02-08-2005, 12:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1