Google Sheets: Rounding DateTime Cell to Nearest 15 Mintutes - google-sheets

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.

Related

How can I set a cell to highlight after X hours have passed in Google Sheets

I have a Google Sheet where a column is filled with times in a 24 hour format (XX:xx), how can I select a cell to highlight red after 3 hours have passed with conditional formatting?
I've been trying to mess with the Now() command in custom formulas for like 2 hours now, but I can't seem to get it to work. PLZ HELP!
To Highlight cells if exactly 3 hours 03:00:00.000 have been passed you need to paste this formula in format>conditional formating. > format cell if - Custom Formula, take a look at the example in this sheet.
=ArrayFormula(IF(A3:A="",,IF(A3:A-NOW()>0.13,"True","False") ))
A3:A-NOW()>0.13 to check if the date in the range A3:A minus NOW() is greater than 0.13 which represent an hour 03:00:00.000 as a number.
To check and highlight cells when certain duration have been passed and be able to adjust the duration from a cell you need to paste this formula in cell B2 to get True or False output.
=ArrayFormula(IF(A2:A="",,IF(A2:A-NOW()>$E$2,"True","False")))
It can be used as a formula in format>conditional formating.
take a look at the example in this sheet.
the columns highlighted in blue is for demonstration it can be deleted.
For anyone who has the same issue, it has been solved. Looks like the Now() call requires both the time and date to be inside the cell in order to work.
The formula I used to highlight cells that are older than 3 hours is
=(Now()-TIME(3,0,0))
A friend also showed me a different formula that seems to do the same thing
=IF(NOW()>A2+3/24,TRUE(),FALSE())
You can change the time by changing the (3,0,0) to Hrs,Min,Sec of your choosing, for the second formula, you can change it by adjusting the fraction value (3/24 for 3 hours, etc)
These will only work if you have the date and time in the cells you are formatting (e.g. If you timestamp with Ctrl+Alt+Shift+;) it will not work if you timestamp with just the time (Ctrl+Alt+Shift) as that seems to set the year to 1899 for some reason.
It would be nice if I could get these working without a date, but I have not found a way to do that.

Show difference between 2 time stamps in seconds and 1/10ths of a second

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

Round down to nearest quarter hour

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

High Stocks. Multi XAxis --- Month wise data not align with big amount of Data Points

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

How to output the correct number in a label?

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]

Resources