Alpha Video Training
Results 1 to 5 of 5

Thread: Calculating time

  1. #1
    Member
    Real Name
    Kev Gray
    Join Date
    Apr 2006
    Location
    Burton on Trent, ENGLAND
    Posts
    27

    Default Calculating time

    Hi, I am returning to Alpha Five after some time. I am trying to create a time management system for my wife's work and I am having trouble creating a calculated field in a table. What I have is -
    Start_time (short time),
    Finish_time (short time),
    Break (short time),
    Hours_worked (short time).

    The calculation I want is (Finish_time - Start_time - Break) to give me the Hours worked and put it in the Hours_worked field. I'm getting "Expression does not equate to a date value" error (see attached).

    I'm sure I doing something basic wrong but can't see what. Can someone put me right please.
    Thanks, Kev

  2. #2
    "Certified" Alphaholic Tim Kiebert's Avatar
    Real Name
    Tim Kiebert
    Join Date
    Jul 2004
    Location
    Geelong, Victoria, Australia
    Posts
    2,785

    Default Re: Calculating time

    You don't need the 'Hours='.
    It is assumed that the result of the expression you are defining is being applied to the field for which you are defining the expression.

    Beware though that a short time minus a short time does not yield a short time. The result will be a numeric value representing the number of seconds between the two.

    This may seem annoyingly inconvenient but does make sense. Time values represent a specific point in time. So the difference between two points in time is not another point in time but a duration which is what your 'hours' field represents.

    Once you have the duration in seconds you can convert that into a character representation of time using the totime() function.

    Same goes for the Break field. It is a duration. You could leave it as a short time but then you would need to get the difference between it and midnight to achieve the duration in seconds. Or Make it numeric representing minutes then multiply by 60. Or make it a character type that represents(looks like) atime and use ToSeconds() to convert it to seconds.
    Last edited by Tim Kiebert; 06-02-2010 at 07:04 AM.
    Tim Kiebert
    Eagle Creek Citrus
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

  3. #3
    Member
    Real Name
    Kev Gray
    Join Date
    Apr 2006
    Location
    Burton on Trent, ENGLAND
    Posts
    27

    Default Re: Calculating time

    Thanks Tim, but still getting a different error... see attached.

  4. #4
    "Certified" Alphaholic Tim Kiebert's Avatar
    Real Name
    Tim Kiebert
    Join Date
    Jul 2004
    Location
    Geelong, Victoria, Australia
    Posts
    2,785

    Default Re: Calculating time

    See the edits to my previous post.

    Wiki page on time and date functions
    Tim Kiebert
    Eagle Creek Citrus
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

  5. #5
    "Certified" Alphaholic Tom Henkel's Avatar
    Real Name
    Tom Henkel
    Join Date
    May 2002
    Location
    New Jersey, USA
    Posts
    1,877

    Default Re: Calculating time

    I think you problem is that the "Hours" field should NOT be a time type field. It is a number of hours worked. Finish - start gives you seconds. MUltiply that by 360 and you'll get hours. It will be a decimal representation, but it is the number of hours. you will need to do a little editing to take the fraction of hours and turn it back into minutes, but you should be able to do that pretty easily.

    Tom

Similar Threads

  1. Calculating Time Difference
    By GaryP in forum Alpha Five Version 9 - Desktop Applications
    Replies: 3
    Last Post: 02-20-2009, 09:24 AM
  2. Problem with Calculating Time
    By demnos in forum Alpha Five Version 7
    Replies: 2
    Last Post: 03-24-2006, 04:15 PM
  3. Calculating Vacation time
    By deputy956 in forum Alpha Five Version 5
    Replies: 2
    Last Post: 06-30-2005, 12:56 PM
  4. Time Calculating
    By Ken L Herrold in forum Alpha Five Version 4
    Replies: 7
    Last Post: 03-24-2001, 12:50 PM
  5. Calculating Time on a Report
    By Dan Blank in forum Alpha Five Version 4
    Replies: 4
    Last Post: 02-16-2001, 12:14 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
  •