Google Sheets conditional formatting based on age in hours - time

I'm trying to conditionally format a column, if the date/time value in the column D is less than 4 hours old, turns yellow. The custom formula I tried is this. Trying to search for solution but cant find much on it
Column D is formatted as "8/23 7:00"
=IF(timevalue($D$2)<NOW()-4)
Tried a different approach that didnt work
=isbetween(now(), now() - 1 / 24)
Also tried
enter image description here

is less than
=now() - 4 / 24
this worked, sheets was lagging to reflect the format

Related

Formulas on Google Sheets

I am hopefully moving up with a promotion at work and have noticed a few things I want to change which will help out our planning.
Using Google Sheets, we create rotas for the jobs for the week and what operatives will be where and in what vehicles.
We update this multiple times during a day and are sometimes seeing people's names or vehicles duplicated across the rota, i.e., Joe Bloggs is showing as at two jobs on the same day.
What formula would allow me to create the rota, but then flag up any duplicates to ensure this doesn't happen?
Select the row in question, go to Format > Conditional Formatting, set Apply to range to all the rows you want to compare, f.ex. A1:A1000, set Format cells if... to Custom formula is and use the =COUNTIF function to count if the cell value occurs more than 1 time, for example =COUNTIF($A:$A, A1) > 1

Google sheets time formatting won't work for me

I'm rather new to google sheets, and I'm trying to make a timesheet that will calculate hours and minutes automatically. The problem I'm facing is that the formula always returns a "#VALUE!"-error because "23:15 is a text and cannot be coerced to a number".
I've formatted the cells to time, but it won't recognize the input as hours and minutes. What am I doing wrong here?
It happened to me too, I discovered that you have to change the location:
File > Spreadsheet Setting > Locale > United Kingdom
you will see that now you can type your time correctly with the ":"
Try going to Format, Number, More Formats, More Date time formats.Select Hour Minute (13:30). Apply this format to all columns (or cells) involved in the calculation.
Here is a copy of my test spreadsheet. I can't get yours to work(?), but this does:
https://docs.google.com/spreadsheets/d/1Qg1JJU9MELesqllHFOhKFO-jxDf1fJMiIVznU1vNP0w/edit?usp=sharing
It is set to your country.

Decimal places on dates, Crystal Reports

Good morning,
I'm currently working on a custom date for a label. It needs to read the last 2 numbers of the current year, followed by the number of day it is within the current year (8/3/2016 would be day 216). So if I were to print a label, the date on 8/3/2016 should read 16216. The following is the current code in the formula:
toText(CurrentDate,"yy") & DateDiff ("d", #1/1#, today) + 1
For reasons I'm unfamiliar with, this returns 16216.00. My question is how do I get rid of the decimal places with this being a text field?
If taken by themselves, toText(CurrentDate,"yy" returns 16 and DateDiff ("d", #1/1#, today) + 1 does return 216. It's only when concatenated that the decimal places appear. Is there a better way to do this?
I'm fairly new to using Crystal, so any help would be appreciated.
Thanks, guys.
You are looking for the Julian date. You have a couple of options
SELECT DATEPART(yy, #date), DATEPART(dy, #date)
SELECT RIGHT(CAST(DATEPART(yy, #date) AS char(4)),2)
The link below goes into much further detail
http://blogs.msmvps.com/robfarley/2009/03/25/converting-to-and-from-julian-format-in-t-sql/

Duration format in google spreadsheet

I'm trying to apply a duration format to some cells in google spreadsheet. I would like to convert an integer number in a format: X days x hours x minutes.
I've tried with some formats like: d:h:mm but i found a problem when I apply the format. It always put one day less. When I write 1 in the cell the convert to 31:0:00. When I write 2 the cells changes to 1:00:00.
That is because the duration format is actually a date / time format (for comparing dates).
If you simply enter a number (1) google will interpret that as midnight (as times are stored as fractions of whole days) of the reference day number 1.
Reference day in Google Sheets is 31/12/1899 - IE the 31st day of the month. That is why your result returns days=31.
To achieve what you want you effectively want to add 1 to your values. so that 1 (+1) actually becomes "2 days since 31/12/1899 - ie 01/01/1900 - ie 1 day, and you could then use custom format for display, but this wont work when you have >31 days.
I think the best way is to simply concatenate the data you have with relavent parts like so (where A1 is a cell containg your data - 1,2,1.5 etc):
=int(A1)&" days "&int(MOD(A1,1)*24)&" hours " & mod(MOD(A1,1)*24,1)*60 & " minutes"

Conditional formatting with data validations

In Google Spreadsheets I have a column of various dates (these are employee's start dates). I want the cells to be highlighted when today's day is within a week of these employee start dates.
I have already been playing with =(B4-TODAY())>7 but this seems to highlight all the past dates.
If this is not possible, just being able to highlight this month's dates is fine (which is easy to do in Excel but can't seem to figure out in Google Spreadsheets).
Then, once this has been done, I have another column with a drop box selection with DONE, and, PENDING.
I would like to conditionally format it so that when DONE is clicked, the highlighted start dates in this month (or 7 days before the day) are highlighted in a different colour.
So it can easily be seen that in 1 week employees are coming, and when done is clicked, we can see their administrative stuff has been dealt with.
Please try =B1="DONE" for the alternative colour and for the +/-7 days:
=and(A1<today()+7,A1>today()-7)
in that order.
=and(…) is used in one of the formulae because the relevant condition is for a bounded range. When I enter =today() in Google Spreadsheets and change that cell’s format to Number I see 41,845.00. Since one week either side makes up the ‘band’ to which attention is to be drawn the relevant values for CF are everything from and including 41,838 to 41,852.
But for display purposes I switch to one day either side, rather than one week, and leave off 41840 throughout, so today becomes represented by 5, and the reduced range of interest therefore 4 to 6 (both inclusive). Of all the possibilities, any value up to and including 3, and 7 or greater, is to be ignored for CF:
The range of interest is everything less than 7 (green) that is also more than 3 (blue):
For “that is also” Google prefers and. In case of any remaining uncertainty creating your own example with a week either side of 41845 etc may help.

Resources