I have a picker view that displays output in a textfield. It is for the user to select an amount of time, it has hours, minutes, and seconds for the 3 rows. For this part I only am focusing on the seconds. I want to be able to convert the hours to minutes and display an output as a whole number and a decimal. I was able to convert the hours to minutes, but I am having trouble converting the seconds into a decimal. It should be as simple as dividing the row count by 60. However, I can't get that to display right. The output to the label is just 0.00 no matter what row i select.. Here is my code.
float sec;
sec = ([timePickerView selectedRowInComponent:2]/60);
Label.text = [NSString stringWithFormat:#"%.2f",sec];
The "/" sign in relation to the number "60" is considered an integer division by the compiler. Change "60" to "60.0" and you shall get the result you are expecting. You should also make sure that the [timePickerView selectedRowInComponent:2] returns a float by casting it:
(float)[timePickerView selectedRowInComponent:2]
Related
Is there a formula that I could use to round a date time cell up or down (1/10/2022 15:17:02) to the nearest 15 minute interval? I've tried MROUND but since the date time field is in a weird format, I can't quite figure out how to get that to work.
Seems to work for me, example here:
https://docs.google.com/spreadsheets/d/1Hq2pep92vmPQ8kPiThNUod7nsFZopMuOAFNcLCdkJcM/edit?usp=sharing
Using =mround(A2,"00:15") to round, =floor(A2,"00:15") to round down, and =ceiling(A2,"00:15") to round up.
Perhaps you forgot to format the end result back as a Date Time itself?
See more examples here: https://infoinspired.com/google-docs/spreadsheet/round-round-up-round-down-hour-minute-second-in-google-sheets/
you can use round to round down
=round(a1*96)/96
or ceiling to round up
=ceiling(a1*96)/96
with date time fields in Sheets the date is treated like a whole number and the time like a fractional part.
so if you want to round to 15 mins - there are 24 * 4 = 96 lots of 15 minutes in one day. so multiply the date by 96, then round, then divide by 96 should do the trick.
I'm looking for a formula to show the time in seconds and 1/10ths of a second between two time stamped cells (produced using CTRL+SHIFT+:) in a Google sheet. The max time between the cells will be less than 1 hour. To make it easy for people to understand it needs to be in the format 123.4 for 123 seconds and 4 tenths. Could anyone help please
You can just subtract the two times and show the result with a custom format of
[ss].0
I have a timesheet which I use for billing clients. It records entries from Toggl as hour fractions, ie 35 minutes is recorded as 0.58. I want to round this number down to the nearest 0.25, ie. the nearest quarter hour. Is this possible in Google Sheets?
After a bit more reading, the function I was looking for is MROUND, to round to the nearest given fraction. eg.
=MROUND(A1,0.25)
The crucial step required is to add or substract half a step depending on whether you want it round up or down, eg.
Up: =MROUND(A1+0.125;0.25)
Down: =MROUND(A1-0.125;0.25)
Added screenshots for clarity:
After many tries with ROUND and MROUND I could only get it to work with FLOOR (rounds down) and CEILING (rounds up).
The following example rounds down to the nearest half hour:
=FLOOR(A1, 1/96)
1/24 for an hour, 1/48 for half an hour etc.
The last thing to do is change the Format of the field to time to get a proper time format:
00:00:00
I was using these multipliers to display months and it actually works fine if I have less points but once I have a more points its just messed up the whole chart..Here is what happened I have 2 X-Axis 1) to display just dates while the other one which is opposite to that x-axis displays Month with Year. This is their requirement so I cant change.
Days wise I use to every other 3 days using (3*24*3600*1000) interval so it work but when I use (30 * 24 * 3600 * 1000) to display months it creates a mess. So let say I have March data point if I see bottom xaxis it looks fine but the month one is way off
I have tried almost all the possible solutions but nothing works out. Any Quick Help will be highly appreciable
I have a float number that could be 3.553 or 34.535 or 353.6436 I want it to be no more than 5 figures, before or after the dot, for example, for the first number I wrote it has to be 3.5530, for the second 34.535 as is and for the third 353.64.
How can I do that with NSNumberFormatter?
Use NSNumberFormatter to convert the number to a string. Specify 5 decimal digits and turn off any grouping. Once you have the string, get the index of the decimal separator. If its index is 4 or less (a number less than 10,000), take the first 6 characters of the string. If its index is 5 or more (a number greater or equal to 10,000), take the first 5 characters of the string.
You may have to adjust this depending on how you want to deal with numbers less than 1 due to the leading zero ahead of the decimal separator.