Alpha Video Training
Results 1 to 3 of 3

Thread: Time Clock Question

  1. #1
    Bob Elliott
    Guest

    Default Time Clock Question

    Hi Board users:

    Can't get this time clock calculations to come out correct anyone see whats wrong! I have attached the program files!

  2. #2
    "Certified" Alphaholic
    Real Name
    William Hanigsberg
    Join Date
    Apr 2000
    Location
    Toronto, ON
    Posts
    4,018

    Default RE: Time Clock Question

    Bob:

    The calculation is in a calculated field rule.There are a couple of problems.
    -the select-case syntax is wrong. You treat it as if it were a simple if function which it is not. Look at the documention on Select-case and you'll see in a second what I'm talking about.
    -the calculation is slightly flawed in that you don't want to use toseconds on the break time field. You need to subtract the number of seconds of the value of the field rather than the number of seconds since midnight.

    Perhaps someone can advise whether select-case would work in a calculated field rule. I would have to experiment to verify its behavior.

    Another, easier, way to approach this would be to write code to the on_depart event of break_time to calculate the total time and insert the value in the total time field. It would be much easier to debug the calculation there. And select case would work fine.

    Bill

  3. #3
    "Certified" Alphaholic
    Real Name
    William Hanigsberg
    Join Date
    Apr 2000
    Location
    Toronto, ON
    Posts
    4,018

    Default RE: Time Clock Question

    Bob:

    I devoted a bit more time (ha ha) to your question. As usual, the devil is in the details.

    Consider the following cut from the interactive window:
    ?toseconds("0100")
    = 100.000000

    ?toseconds("01:00")
    = 3600.000000

    You can see that the ":" changes how the function interprets the time string. Since you had checked "do not store mask literals" in field rules, the expression calculating total time never saw a colon. So I unchecked the option. The calculation works now.

    Calculated rule for total time field:
    TOTIME(TOSECONDS(TIME_OUT)-TOSECONDS(TIME_IN)-TOSECONDS(BREAK_TIME),1,0)

    Note that I eliminated the need for a conditional calculation by using a validation rule on a different field to make sure the times are in the proper order.

    Validation expression for Time_OUT field:
    TOSECONDS(TIME_OUT)>TOSECONDS(TIME_IN)

    A more elegant user experience could be produced by writing event code at the form level but then it would have to be reproduced on every form. Validating via field rule is thus a bit easier.

    A demo is attached. Open it in its own folder.

    Bill

Similar Threads

  1. Time clock function
    By ggreb in forum Alpha Five Version 5
    Replies: 8
    Last Post: 03-02-2005, 04:01 PM
  2. Time Clock Application
    By imwest@cox.net in forum Alpha Five Version 5
    Replies: 4
    Last Post: 10-28-2003, 03:34 AM
  3. Toolbar Clock
    By JerryBrightbill in forum Code Archive
    Replies: 0
    Last Post: 12-20-2002, 05:55 AM
  4. 2nd Time, same question on refresh
    By Beltronics in forum Alpha Five Version 5
    Replies: 12
    Last Post: 11-27-2002, 07:13 AM
  5. Time Clock-Code help
    By russ Boehle in forum Alpha Five Version 4
    Replies: 7
    Last Post: 05-04-2002, 10:01 AM

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
  •