Ron Cates Posted June 7, 2012 Posted June 7, 2012 I'm currently working on a time clock and I would like to be able to set fields with the current time but without the seconds. I know I can format to display only hh:mm but if the time needs to be editted when the field is clicked into it shows hh:mm:ss which I would prefer to simplify for managers and such who may need to make edits. So is there a way to trim the seconds off Get ( currentTime ) so that the actual value entered into the field is hh:mm rather than hh:mm:ss ?
Lee Smith Posted June 7, 2012 Posted June 7, 2012 How is the time entered now, i.e. manually, auto enter or script?
jbante Posted June 7, 2012 Posted June 7, 2012 GetAsTime ( Floor ( Get ( CurrentTime ) / 60 ) * 60 ) 1
comment Posted June 7, 2012 Posted June 7, 2012 if the time needs to be editted when the field is clicked into it shows hh:mm:ss which I would prefer to simplify for managers and such who may need to make edits. So is there a way to trim the seconds off Get ( currentTime ) so that the actual value entered into the field is hh:mm rather than hh:mm:ss ? If it's a Time field, then the seconds will be there even if you decimate them to zero as suggested by Jeremy. OTOH, you could use a Text field and populate it by setting it to = Let ( t = Get ( CurrentTime ) ; Hour ( t ) & SerialIncrement ( ":00" ; Minute ( t ) ) )
Ron Cates Posted June 7, 2012 Author Posted June 7, 2012 It is a time field and I find that when I type in a time as hh:mm it remains that way. For example if in the morning I type in 7:45 it remains 7:45 and just adds the AM. The value ends up as 7:45 AM. I also have an auto enter field that uses Timestamp ( date ; timein ) and the resulting timestamp remains without the seconds as well which is also what i preffer. But now I am trying to use a clock in and out script attached to a button rather than having the user type in thier times. GetAsTime ( Floor ( Get ( CurrentTime ) / 60 ) * 60 ) Thank you Jeremy. This works perfectly
Ron Cates Posted June 7, 2012 Author Posted June 7, 2012 I'm just glad it does. And the total hour calculations work accurately with this in place as well.
comment Posted June 7, 2012 Posted June 7, 2012 Well, the thing is that when you don't know why it's working, you don't know when it will stop working....
jbante Posted June 8, 2012 Posted June 8, 2012 If it's a Time field, then the seconds will be there even if you decimate them to zero as suggested by Jeremy. This has never been the case in my experience. FileMaker time fields apparently store more than just a number of seconds, along the same lines as how number fields can store text data which is simply ignored for many operations. Time fields apparently preserve some formatting from the originally entered data, and a field on the layout may display that original format if formatting options are set to "As Entered". My initial thought was that FileMaker will sometimes do interesting things to calculation values when type casting (such as casting a time as a number to do the calculation I suggested). But then I did some testing, and it got weird. Let ( [ ~now = Get ( CurrentTime ); ~time = Time ( Hour ( ~now ) ; Minute ( ~now ) ; Seconds ( ~now ) ) ]; List ( "## " & ~now; GetAsTime ( Floor ( ~now / 60 ) * 60 ); "## " & ~time; GetAsTime ( Floor ( ~time / 60 ) * 60 ) ) ) Which gave me the result: ## 11:04:48 AM 11:04 AM ## 11:04:48 11:04:00 It seems as if the GetAsTime gives the result of Get ( CurrentTime ) different treatment than the output from the Time function, even after being cast as a number for the math.
Ron Cates Posted June 11, 2012 Author Posted June 11, 2012 For the sake of consistancy I tried using the calculation in a replace field contents operation to eliminate the seconds from the existing data. GetAsTime ( Floor ( TimeCards::TimeStart / 60 ) * 60 ) It didn't work at all. But it's no big deal, I can live with the current data as is. But it does seem to show that it only works using Get ( CurrentTime ).
Ron Cates Posted June 11, 2012 Author Posted June 11, 2012 I have another request if anyone would care to help? As a little background The Time Card solution I am working on was converted and integrated from the Time Card starter solution included with FMP 11 for the sake of saving time rather than building one from scratch. In a perfect world I would probably use seperate records with a clockIn and clockOut field. However the starter solution uses a single record for each week and uses repeating fields for clocking in and out for each day. It has a single ClockIn field and ClockOut field and a single Lunch field for entering how much time a person took for lunch. Each of the fields has 7 repetitions, one for each day of the week. To expand the solution at the request of my manager I added a second set of clockin and clockout fields to allow for clocking in and out for lunch, and a third set fot the occasional need to clock in and out to run errands and such. I have a total hours field that calculates the time worked. I actually show a time field but use an underlying auto entered timestamp field to calculate the total hours worked. The calculation is as follows: Round( ( Hour( timeStampOut1 - timeStampIn1 ) + Minute( timeStampOut1 - timeStampIn1 ) / 60 ) ; 2 ) + Round( ( Hour( timeStampOut2 - timeStampIn2 ) + Minute( timeStampOut2 - timeStampIn2 ) / 60 ) ; 2 ) + Round( ( Hour( timeStampOut3 - timeStampIn3 ) + Minute( timeStampOut3 - timeStampIn3 ) / 60 ) ; 2 ) - adjust // This is an additional field to allow the manager to adjust the total hours if needed. After a user has clocked in and out the total hours for the day is displayed. This value is then used to calculate how many hours are worked for the week and how many hours are left to reach the 40 hour work week. However, while the user is currently clocked in the total hours worked and all subsiquent calculations show only a "?". What I would like to do is be able to use Get ( CurrentTime ) to show the user how many hours they have worked up until the current time while they are still clocked in, which in turn will also make the other calculations valid as well. Can anyone help me with a calculation that will use the current time if the user is currently clocked in? The sample images show just one clock in time and one clock out time but I would need the calculation to use Get ( currentTime for any combination of clockins and clockouts that leave the user currently clocked in.. Currently the adjust field is subtracting the hours entered. I haven't gotten to formatting it the way I want it where it would add if the number is possitive or subtract if the number is negative. But please just disreguard that issue for now..
Recommended Posts
This topic is 4548 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