Im newbie on excel/spreadsheets and I want to do this:
I have a table with one column that contains some intervals with "Steeping times" like 7-15 days (I can change format).
And I have another column with "Recipe Created" (12/02/2017).
What I want is to check if "Current Date/Local date - Recipe created" is between the interval or if it's less or more.
Example:
Steeping time = 7-15
Current Date 18/07/2017 (spanish format) - Recipe created 10/07/2017 = 8
8 is between Steeping time? Yes.
If it is then paint a cell with yellow, if its less than 7 paint it red and if it is more than 15 paint it green.
Maybe its not an IF function but I would do this with IF on javascript
Thanks in advance.
In Google sheets at least, use Format, Conditional formatting. Set the default to be yellow. Add a rule that if the value is less than 7, red. Add a rule that if the value is greater than 15, green.
You can probably find lots of information on calculating date differences all over stack overflow. The date (only, no time) now is:
=date(year(now()),month(now()),day(now()))
To parse your date which was in A2 I did (and there may be easier or more robust ways)
=left(A2,2) for the day
=mid(A2,4,2)
for the month
and =right(A2,4)
for the year then made a date of those as above. Then I put the difference of the 2 dates in a cell and applied conditional formatting based on its contents.
Related
I am using a spreadsheet to record the intervals between certain medical events. Each event's timestamp is recorded in one column, so the interval between each event is the difference between consecutive cells (and the time since the last event uses now()).
First problem: I want to display the interval in days, hours and minutes. None of the built-in formats will do this, they report the days remaining after discarding complete months. So I am using this expression:
TEXT(TRUNC(C2-C1),"0") & " days " & TEXT(MOD(C2-C1,1),"hh "" hrs "" mm ""mins""")
which (e.g.) shows "46 days 13 hrs 44 mins". I was hoping there was a way to format a date/time value to show this rather than making the cell a string value, but I haven't been able to find one.
Second problem: I want to display the average value of all completed intervals in the same format. Because I can't average the string values produced by the previous expression I need to average the numeric equivalent (which I'd prefer not to have visible in the sheet) and then convert it to a string as for a single interval.
I can probably do this with a similar approach (if I don't run out of characters to enter the formula) but it seems to me that there must be a better way.
Ideally there is a solution which will work in Excel 2010. Has anyone solved a similar problem before and can give me some pointers?
Thanks, T
Edit: Some data to show what I am working with (I hope the image is readable). Here's a few lines from the sheet.
The formula for H2 etc. is
=IF(G2="c",NOW()-C2,"")
I5 is calculated as the difference between C5 and Cprev (where prev is chosen so that D5 and Dprev are both set). Obvious extension of this for J and K.
M2, M3 and M4 are respectively
=AVERAGEIF(K5:(INDIRECT("K"&(ROWS(K:K)))),"<>0")
=AVERAGEIF(J5:(INDIRECT("J"&(ROWS(J:J)))),"<>0")
=AVERAGEIF(I5:(INDIRECT("I"&(ROWS(I:I)))),"<>0")
Now, I can use a custom format for the values in H, I and J, and for M3 and M4, because these values will never exceed a few days. But values in K and M2 will be somewhere around 100 so I can't just format the raw value.
With custom formatting applied:
Here K6 and M2 say "27 days.." not "87 days..". That's what I'd like to fix nicely, hopefully without populating additional cells or writing a 3gl function to do it.
Date_Times in Excel are stored as days (with the decimal part representing parts of a day).
If the date matters, rather than just a number of days, then day zero is 1899/12/31.
Your first thought was right - do with formatting, not by turning a number into a string.
Entering date into A and time into B, with C=A+B is a good start, so that you can E.g. subtract one point in time from another without having to do anything about straddling midnight, month-ends etc, calculate averages etc.
Consolidating the comments already here: per https://support.microsoft.com/en-us/office/format-numbers-as-dates-or-times-418bd3fe-0577-47c8-8caa-b4d30c528309 you cannot get d for days above 31 (and it won't accept a format 0 hh:mm:ss )
I suggest that you do all your calculations using just numbers to get to say column M, and in N2 put =M2 etc, so you have the same values twice.
Then for formatting, use Format Cells | Number | Custom.
In column M put 0 "days".
In column N put hh "hours" mm "minutes".
I have a column of years, 2000, 1990 > 900 (0900) > 1876 etc.... However I needed to have it in a date format e.g. 01/01/2000, 01/01/900 (01/01/0900). I can't work out how to do this. I can only see formulas which add days and months which are already in the format I would like. I only need it as 01/01 to input to QGIS as a csv file.
Dates are represented in Excel by real numbers. The integer part (to the left of the decimal place) is the number of days since 12/30/1899. The fractional part (to the right of the decimal place) is the fraction of the day. .5 = noon, .75 = 6pm, etc. How these numbers appear in the worksheet depends on the number format of the cell. So if your cell value is 36526 (or 1/1/2000) and the number format is "mm/dd/yyyy" you will see '01/01/2000' in the cell. If the number format is "mm/dd", you will see '01/01' in the cell.
I don't understand what you mean by "I only need it as 01/01 to input to QGIS as a csv file" but if you show me some code, and explain how the results you're getting differ from the results you want, I can probably help get you there.
I have column in Excel containing Date in the format given below and I want to count the cells having specific data not the time. For instance I want to count cells containing 7/29/2008 in the below data it must give 3. I have tried =countif(range,"7/29/2008") but result was 0.
7/28/2008 5:28:51 AM
7/29/2008 5:30:53 AM
7/29/2008 5:33:25 AM
7/29/2008 5:38:15 AM
7/30/2008 5:39:36 AM
How to achieve this?
With your data in A2:A6 try this,
=COUNTIFS(A2:A6, ">="&DATE(2008, 7, 29), A2:A6, "<"&DATE(2008, 7, 30))
With 07/29/2008 in B1 this would be,
=COUNTIFS(A2:A6, ">="&B1, A2:A6, "<"&(B1+1))
I was attempting to do this as well. My problem was trying to extract the date only from datetime formatted cell (using a custom formatting, m-d-yyyy h:mm). Internally, dates are stored as Excel date serial numbers in the form of xxxxx.yyyyyy. I tried to find ways of pattern matching, trimming, and extracting formats from the cell range within the formula and was pulling my hair out (what I have left).
Then, I started to discover that if you set the cell value as a date without specifying a time, it would pattern match if the time was also matched. In this case, without specification, the default time was 12:00 AM. As soon as I started to match other dates with any other time specified, it would fail.
In my case, this is true: >= of today'sdate and the <= to tomorrow solved the issue based on Excel's default time of midnight (which is used if the time is not specified).
I have a data file imported where there is a column for the date. It is custom formatted as [-$409]ddmmmyyyy h:mm:ss:000 so that it takes a number like 41769.68 and has it shown in the cell as 10May2014 16:23:04.883, for instance.
I want to be able to take just the hour and use that for conditional formatting though. For example, if the hour is between 7AM and 11AM, I want another column to say 'morning', or something of that sort. I know I can change the format cells option to just 'h' to get the hour, but using that in another block of code still returns the original 41749.68 number rather than 16, for example.
Is there a way to get just the hour to show in its actual number form rather than the whole date, or if not, is there a way to parse the number 41769.68 to find the hour?
The hour is .68 (the decimal part) *24 (each day is 1 unit to Excel). If you don't want the minutes then either round or truncate (eg with INT). Either way Conditional Formatting will not allow you to format as 'morning'.
You could try:
=HOUR(A1)
With your value in A1, in another cell enter:
=INT(24*(A1-INT(A1)))
will display 16
Is it possible to have Excel return a date when counting down to a date from a specific date that is NOT today or now?
Ex: End_date is 04/22/14 and data that I have is "2 weeks before", "3 days before", "4 months before", etc. So I want the cells with "3 days before" to display the date (04/19/14)
I've found info on counting down from today:
=DATEVALUE("22-April-2014")-TODAY()&" days remaining"
but this displays the time remaining and I need the TODAY to be replaced with a value that represents "2 weeks before" April 22 AND for the return to be a dat
This may not be possible :/
Further to my comment above, since your post doesn't mention that you will have text like 1 month before or 2 years before, I am going to assume that they are not there. If they are then we will have to slightly tweak the formula.
Let's say your data looks like this (Ignore the cells in red. I am still experimenting with it)
Simply add this formula in Cell B2 and pull it down
=(LEFT(A2,SEARCH(" ",A2,1)))*(VLOOKUP(TRIM(MID(A2,SEARCH(" ",A2,1),SEARCH(" ",A2,SEARCH(" ",A2,1)+1)-SEARCH(" ",A2,1))),F:G,2,0))
and this in C2 and pull it down
=DATEVALUE("22-April-2014")-B2
Also Add a small table for lookup in column F:J as shown in the image below
Explanation
I am using Left/Search/Mid to extract the numerical part and the text after that which could be Day/week/Days/weeks/fortnight/fortnights/Months/Years/Month/Year and then using a Vlookup to find the equivalent in days.
So if I break this =(LEFT(A2,SEARCH(" ",A2,1)))*(VLOOKUP(TRIM(MID(A2,SEARCH(" ",A2,1),SEARCH(" ",A2,SEARCH(" ",A2,1)+1)-SEARCH(" ",A2,1))),F:G,2,0)) up for the first cell, I get
(LEFT(A2,SEARCH(" ",A2,1))) = 3 and
(VLOOKUP(TRIM(MID(A2,SEARCH(" ",A2,1),SEARCH(" ",A2,SEARCH(" ",A2,1)+1)-SEARCH(" ",A2,1))),F:G,2,0)) = 7
and hence = 3*7 =21
(VLOOKUP(TRIM(MID(A2,SEARCH(" ",A2,1),SEARCH(" ",A2,SEARCH(" ",A2,1)+1)-SEARCH(" ",A2,1))),F:G,2,0)) can be further broken up
TRIM(MID(A2,SEARCH(" ",A2,1),SEARCH(" ",A2,SEARCH(" ",A2,1)+1)-SEARCH(" ",A2,1))) will give you Weeks and once we know that we do a simple lookup.
Challenges
Like I mentioned, if you have months and days then there can be multiple values for them. See the table.
If the text consists days,weeks,months and years then this solution helps.
in cloumn C add formula ==MID(A1,FIND(" ", A1)+1,3) and drag it down.
in column B add formula =IF((C1="day"),($B$1-LEFT(A5,1)),IF(C1="wee",($B$1-(LEFT(A5,1)*7)),IF(C1="mon",EDATE($B$1,-LEFT(A5,1)),IF(C1="yea",EDATE($B$1,(-LEFT(A5,1)*12))))) and drag it down.
If EDATE() function is not available, and returns the #NAME? error means install and load the Analysis ToolPak add-in.
visit HERE to Load Analysis ToolPak for Excel.
Below is the snap shot of solution.