Newbies Pete F Posted November 4, 2010 Newbies Posted November 4, 2010 Hey everyone! I'm new here so don't bite my head off. I appreciate any and all advice. Anyway I am looking to create a way to create a field that acts like a timer. Basically what I have thought about doing is creating two timestamp fields: "Start" and "Stop". From there I created two buttons with matching names on my layout each with a function of Insert Current Time into their respective fields. Then I created a third field called difference, to see if I could create a calculation field that would subtract the Stop timestamp from the Start timestamp. Here is where I ran into trouble. I tried to have the results come up in a number format, which ends up being in seconds, but I can't figure out how to make the formatting of the field come up as "0:05". Any tips? Thanks a bunch in advance!
comment Posted November 4, 2010 Posted November 4, 2010 Set the calculation's result type to Time. BTW, it's better to use Set Field[] instead of Insert.
James Gill Posted November 4, 2010 Posted November 4, 2010 (edited) I'll throw my two cents out there as far my time tracker solution is concerned. Personally, I think this solution should need one field; Duration. I had a need for basically the same thing as you; a way to track the time spent on a particular task. I feel that whatever solution is used, the less fields added to a database the better. What I did is create a single script that uses four global variables. If ( get ( ScriptParameter ) = "Start" ) $$timer_start_date = get (CurrentDate) $$timer_start_time = get (CurrentTime) Else if ( get ( ScriptParameter) = "Stop" ) $$timer_stop_date = get (CurrentDate) $$timer_stop_time = get (CurrentTime) Then I just set one field with a calculated result containing a formula I found online that gives me duration in days, minutes, hours and seconds. Two buttons control it; one button passes a script parameter for start and one for stop. On clicking the stop button, a formula is applied to whatever field you need to paste duration into. You could even pass the calculation as a variable and have a timer solution that doesn't use a single field in a database. I've pasted the calculation below: Hour ((($$timer_stop_date-$$timer_start_date) * 86400) + $$timer_stop_time - $$timer_start_time) & (If (Hour ((($$timer_stop_date-$$timer_start_date) * 86400) + $$timer_stop_time - $$timer_start_time) = 1; " hr, "; " hrs, ")) & Minute ((($$timer_stop_date-$$timer_start_date) * 86400) + $$timer_stop_time - $$timer_start_time) & (If (Minute ((($$timer_stop_date-$$timer_start_date) * 86400) + $$timer_stop_time - $$timer_start_time) = 1; " min, "; " mins, ")) & Seconds ((($$timer_stop_date-$$timer_start_date) * 86400) + $$timer_stop_time - $$timer_start_time) & (If (Seconds ((($$timer_stop_date-$$timer_start_date) * 86400) + $$timer_stop_time - $$timer_start_time) = 1; " sec "; " secs ")) Granted, it looks daunting, but once you realize that it's using two global variables to do all the work, you can implement this technique pretty easily in any solution. Hope this helps! Edit: Now that I think about it, you could basically do the same thing using two global variables if you chose to use the get (CurrentTimeStamp) feature... Edited November 4, 2010 by Guest
comment Posted November 4, 2010 Posted November 4, 2010 you could basically do the same thing using two global variables How about just one? However, using variables this way means you can time only one task at a time. Perhaps there should be a separate variable for for each task - or store the start timestamp in a field ... See also: http://fmforums.com/forum/showtopic.php?tid/214744/post/356284/#356284 Timer.zip
James Gill Posted November 4, 2010 Posted November 4, 2010 Interesting. As far as tracking multiple records, couldn't you just tack on the Primary Key value of a field to the variable? Obviously this assumes that the primary value is unique to each table if you're tracking multiple values over different tables, but that seems like a pretty slick way to accomplish multi-attribute tracking.
comment Posted November 4, 2010 Posted November 4, 2010 (edited) Yes, you could - see here for something very similar: http://fmforums.com/forum/showtopic.php?tid/214676/ But I would still use a field, because I'd like to record not only 'how much' but also 'when'. Edited November 4, 2010 by Guest
Newbies Pete F Posted November 5, 2010 Author Newbies Posted November 5, 2010 Wow! Thanks everyone, this information is really really helpful so far. I had no idea people would take interest in such a simple task, but I appreciate it big time. The reason that I wanted to use two buttons was so that when I clicked on "Stop" it would add a new record with the duration filled in for me. You see I am creating a piece of software for filmmaking, and one of the things I am trying to accomplish is to have it keep track of how long each camera is filming when they call out "Action!" and "Cut!". Depending on the project I am working on, sometimes they will only use one camera, so I would only need to keep track of the time of one camera. But other times they will use three cameras called "A" "B" and "C". So eventually I would like to be able to go into my database, identify each camera within the database, and then have the timer automatically add a record for each camera with the duration filled in. I know this may seem a bit more complicated than what I originally asked, but your help has inspired me! Thanks again everyone! -Pete
mtk Posted November 27, 2010 Posted November 27, 2010 I'll throw my two cents out there as far my time tracker solution is concerned. Personally, I think this solution should need one field; Duration. I had a need for basically the same thing as you; a way to track the time spent on a particular task. I feel that whatever solution is used, the less fields added to a database the better. What I did is create a single script that uses four global variables. If ( get ( ScriptParameter ) = "Start" ) $$timer_start_date = get (CurrentDate) $$timer_start_time = get (CurrentTime) Else if ( get ( ScriptParameter) = "Stop" ) $$timer_stop_date = get (CurrentDate) $$timer_stop_time = get (CurrentTime) Then I just set one field with a calculated result containing a formula I found online that gives me duration in days, minutes, hours and seconds. Two buttons control it; one button passes a script parameter for start and one for stop. On clicking the stop button, a formula is applied to whatever field you need to paste duration into. You could even pass the calculation as a variable and have a timer solution that doesn't use a single field in a database. I've pasted the calculation below: Hour ((($$timer_stop_date-$$timer_start_date) * 86400) + $$timer_stop_time - $$timer_start_time) & (If (Hour ((($$timer_stop_date-$$timer_start_date) * 86400) + $$timer_stop_time - $$timer_start_time) = 1; " hr, "; " hrs, ")) & Minute ((($$timer_stop_date-$$timer_start_date) * 86400) + $$timer_stop_time - $$timer_start_time) & (If (Minute ((($$timer_stop_date-$$timer_start_date) * 86400) + $$timer_stop_time - $$timer_start_time) = 1; " min, "; " mins, ")) & Seconds ((($$timer_stop_date-$$timer_start_date) * 86400) + $$timer_stop_time - $$timer_start_time) & (If (Seconds ((($$timer_stop_date-$$timer_start_date) * 86400) + $$timer_stop_time - $$timer_start_time) = 1; " sec "; " secs ")) Granted, it looks daunting, but once you realize that it's using two global variables to do all the work, you can implement this technique pretty easily in any solution. Hope this helps! Edit: Now that I think about it, you could basically do the same thing using two global variables if you chose to use the get (CurrentTimeStamp) feature... Hello All, I've got a similar problem to this one but have been unable to figure it out. I've got the start, stop, and calculation for the difference between the two. It is in time format. Say 01:20 (1 hr and 20 minutes) My problem is that I want to change the time into point values. For every 1 hr or 15 minute segment of an hour a person earns 1 point. There are two problems I need help on here. 1. How do I get the time to translate into a number that can have 2 decimal places. I know how to change from time to number but it does not compute the quarter of an hour. 2. How do I get the time of :20 to round down to .25 or a quarter of an hour. In other words the 20 minutes is closer to 15 minutes than it is 30 minutes so I want to credit the person with a quarter of an hour. If worker worded 27 minutes I would want it to round UP to .5 of an hour. HELP. Thanks in advance for looking at this. mtk
comment Posted November 27, 2010 Posted November 27, 2010 For every 1 hr or 15 minute segment of an hour a person earns 1 point. This is not quite clear. It could mean 1 point per hour, with 15 minutes or more rounded up to a full hour - but this doesn't fit what you said later. Or it could mean 0.25 points per 15 minutes.
mtk Posted November 28, 2010 Posted November 28, 2010 This is not quite clear. It could mean 1 point per hour, with 15 minutes or more rounded up to a full hour - but this doesn't fit what you said later. Or it could mean 0.25 points per 15 minutes. Sorry for the confusion. You are quite right that my posting was unclear. Here's what I meant to ask. 15 minutes = .25 of an hour or .25 of a point 30 minutes = .50 of an hour or .50 of a point 45 minutes = .75 of an hour or .75 of a point 60 minutes = 1.0 of an hour or 1.0 point Your way of saying 0.25 per 15 minutes is probably the best way to do this. Hmmmm. I want to be able to add the points up. We count time in increments of 15 minutes. All times need to be rounded up or down to the nearest 15 minute interval. Thanks for replying! mtk
comment Posted November 28, 2010 Posted November 28, 2010 Try = Round ( time / 900 ; 0 ) / 4 The result type should be Number.
mtk Posted November 28, 2010 Posted November 28, 2010 OMG you are brilliant. It works! I have no idea why it works, but it is giving me the exact result I want. Thanks so much for taking the time to help. You are appreciated. mtk
comment Posted November 28, 2010 Posted November 28, 2010 It works because time, when converted to a number, is expressed in seconds. Dividing by 900 returns the number of quarter-hours. You round this to the nearest integer and divide the result by 4 to assign 0.25 points to each quarter-hour.
Stickybeak Posted December 9, 2010 Posted December 9, 2010 I would like to be able to start the time calculation, stop it but also to pause and rsume it. I don't need to see the time running
Lee Smith Posted December 9, 2010 Posted December 9, 2010 I would like to be able to start the time calculation, stop it but also to pause and rsume it. I don't need to see the time running Maybe one of these will get you started http://fmforums.com/forum/index.php/topic/42759-a-timer-idea-im-kicking-around-for-use-in-my-project-beta-8-advanced/page__p__199541#entry199541 http://fmforums.com/forum/index.php/topic/58458-the-perfect-timer/page__p__277093#entry277093 HTH Lee
Ron Cates Posted December 9, 2010 Posted December 9, 2010 OMG you are brilliant. It works! I have no idea why it works, but it is giving me the exact result I want. Thanks so much for taking the time to help. You are appreciated. mtk Ding, Ding, Ding! Congratulations, you are the 1 Millionth person to tell Comment he is brilliant! Enjoy the balloons falling from the cieling : Now you have to buy him a virtual beer.
comment Posted December 9, 2010 Posted December 9, 2010 Congratulations, you are the 1 Millionth person to tell Comment he is brilliant! That was in November. We are in December now... :
Recommended Posts
This topic is 5146 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now