1. ## 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. ## 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.

3. ## Re: Calculating time

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

4. ## Re: Calculating time

See the edits to my previous post.

Wiki page on time and date functions

5. ## 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

#### Posting Permissions

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