How display month(s)-long data per day? - excel

I have an amount of data sort per date (e.g : 2013-12-12 10:51:51.000) and I want to display that data on a day-long plot : The plot will show the sum values or the % for each hours of the day from 0:00 to 23:59.
My problem is I don't know how to sort data "modulus day", since the date is store in one cell and so day and hours are not separates.
Thank you for your help

The Date in Excel cell is stored as a decimal, where integer part corresponds to Date and decimal to time after midnight, so for example 6/30/2014 9:00 is essentially equal 41820.38. Thus, the sorting should work perfectly fine: it will be using underlying numeric representation of Date and Time as explained above.
Pertinent to your further requirement, i.e. to sort only on time part (decimal) ignoring Date (integer) the solution might be as following: Assuming Date is stored in Column A (cell A1 for example), put a formula in Column B (cell B1)
=A1-INT(A1)
and extend it to entire range, then sort on Column B. Optionally, for your convenience, you can convert the cell format in Column B to Number (to view just decimal part).
Rgds,

Related

Convert HH:MM values to H in the same column

Is there a way for me to format a column where the values I enter in the format HH:MM (elapsed time, not datetime) are converted to hours in decimal, preferably in the same column via some custom formula?
For example,
HH:MM
H (Decimal)
07:39
7.65
02:15
2.25
06:00
6
At the moment, I manually calculate the equivalent and enter them into the column but it would be nice to directly copy a timestamp and have the column automatically format it but I couldn't see an option for this in Date/Time formatting settings.
Simply multiply your hh:mm durations by 24, ensuring that the cells where you want the decimal hours returned are formatted as 'Number'. Or to force formatting as a number using a formula: =text(duration_cell*24,"#.##") where duration_cell is a cell with the duration in hh:mm format.
There is no way to do that I know of because Excel stores times/dates as floats. Each 24 hour period equals 1, therefore 7:33 equals .31458 Therefore, you won't be able to do this without a helper column.
You can do this with either #The God of Biscuits answer, or alternatively your helper column can have the formula:
=(A1*24)
and you set that column's cell format to Number.
All date and time is a format of a double value.
Time is the amount after the comma.
And all in front of comma is days since 00.01.1900.
Meaning 07:37:00 = 0,32 days.
Excel have a ways to pull the amount of hours with =HOUR('Your referance date time cell value')
You can aply this formula: =HORA(A2)+(MINUTO(A2)/60)

Find End & Start Date Double Vlookup Excel

I have thousands of cells of data formated with the headers of
UID, Date, Mass, Start / End, Float Days, Days from Start
I have a simple version of what the sheet looks like below:
Each new data entry is entered as a row.
The data for each UID ( unique ID) is taken on non-consistent days over the length of its float life. (ex: wood floats and I take its mass on different days until it sinks).
I want to Identify a "Float Days" by taking the Sink date and subtracting it by the first reference of the ID.
#simple:
When the row has "1" in the D column, Find the ID on that row, then find that ID when that row has "0".
Take the date from that row and subtract by sink date to give me float days
#complex:
=IF(D16="1", (vlookup(A16 & "0",$A$1:$F$999,2,0)-B16, "")
If possible, I would like to use the framework of the formula to also calculate each data-inputs date in days from its Start Date as shown below:
#simple: in row E
Take the date from current row (row 10 for example), find that ID's start date,
subtract from one another to give me days from time=0
#complex:
=B10-vlookup(A10 & "0",$A$1:$F$999,B,0)
I am confused as to whether I am typing the formula incorrectly or if there is another and easier way to do this.
Thank you!
SUMFIS is the better choice here. In cell E2 and copied down:
=IF(D2=1,B2-SUMIFS(B:B,A:A,A2,D:D,0),"")
If you want a same day start/end pair to be equal to 1 instead of 0, just add a +1 to the end of the SUMIFS.

excel date time formula issue

I'm struggling to make a formula work in excel.
My case : I have data in m/d/yyyy h:mm AM/PM format on E col.
I have data that goes to the next day post midnight. I'm looking to create another column lets say F where I want to check for data between time 5:30pm to next day 5:30am and return date in m/d/yyyy(col F)
Example :
Let's say a job request came in at 3/21/2021 4:30am, I want it to return 3/20/2021 on col F (previous date)
This is required due to different timezone and unfortunately the timezone cannot be altered on the data.
If it's really true that your data are in "m/d/yyyy hh:mm PM format" then this formula will deduct 8 hours from the value found in E4 and return a true date.
=DATE(RIGHT(LEFT(E4,FIND(" ",E4)-1),4),LEFT(E4,FIND("/",E4)-1),MID(E4,FIND("/",E4)+1,1+ISERROR(FIND("/",MID(E4,LEFT(E4,FIND("/",E4)-1),2)))))+TIMEVALUE(MID(E4,10,10))-(8/24)
A "True" date is a number which takes its display format from the cell format you set, meaning the "data" are different from the display. A "Fake" date (my expression) is a text string that looks like a date but is unsuitable for calculations because it's not a number. The "data" underlying a fake date are identical to the display. My above formula spends 95% of its effort on converting the fake date into a true one and is likely to earn your comment that it "doesn't work" because it returns a number. If so, don't comment. Set the cell format to the kind of display you want.
Of course, if E4 has a true date the effort can be reduced and the formula you seek would be simply
=E4-(8/24)
This is because in Excel dates one day has a value of 1. Therefore 1 hour = 1/24 and 8 hours = 1/24*8 or 8/24. Change the number of hours as desired, add or subtract them from the original as needed.
BTW, if your original data are really text (fake dates) do consider converting them to true dates using the 95% part of my first formula and then processing them as true dates. As you see, there is no advantage in keeping fakes around.

Create a timestamp given date values columns in Excel

I have a date in the following format:
Column A: Day (number form)
Column B: Month (number form)
Column C: Year (yy number form, in my case just 15 and 16 for 2015 and 2016)
Column D: Hour (number form, 0 through 23)
Column E: Minute (number form)
How can I convert this into a timestamp (namely, a timestamp representing number of minutes)? I don't see any kind of "dateserial" type function in Excel (at least on my Mac version).
You can do it with this formula:
=DATE(2000+C1,B1,A1)+TIME(D1,E1,0)
This will get you a number around 42000, you will need to format it in the number format you want.
Then if you want to time difference between two rows you would simply use:
=F2-F1
And format the cell with a custom format of [hh]:mm:ss
Note the method that excel stores date/time is:
Dates are whole numbers for each day since Jan 1st 1900 so we are currently in the 42000's.
Time is a decimal based on 24 hours being 1.
So both together my current time is 42531.63956 or 6/10/2015 3:21:33 or so, when the mask is applied.
Excel uses this method so we can do math on the values. The method on how the output is displayed depends on the format of the cell in which the number resides.
Something like this should work:
=DATE(CONCATENATE("20",C1),B1,A1) + TIME(D1,E1,0)

Finding the value in excel or vba

Column A Column B
13-06-2013 10:50
13-06-2013 11:30
13-06-2013 12:40
14-06-2013 10:30
I need to find the values which are before a particular entry date and time.
For example, say I want to find the values in the example table above that are immediately prior to the values "13-06-2013" and "12:30".
Since 12:30 is not in column B, how do I find the values I am looking for? The answer should be 13-06-2013 and 11:30.
C7 =VLOOKUP(A7&B7,A1:C4,3,TRUE)
Here A1 = B1&C1
A B C
1 414380.451388888888889 13-06-2013 10:50
2 414380.479166666666667 13-06-2013 11:30
3 414380.527777777777778 13-06-2013 12:40
4 414390.4375 14-06-2013 10:30
5
6 Enter date Enter Time Returned Time
7 13-06-2013 12:30 11:30:00
Setting 'range_lookup' as 'True' adds the flexibility to return the closest approximate value if the exact value is not available.
I think you're looking for something like this. using index and match.
I didn't take into account the date for now. but this gives you an example.
You can compare date strings with operators like > or < etc. Concatenate your values in columns A & B, compare to the desired date/time string. In cell C1 put the following formula, and then drag down:
="13-06-2013 12:30"<A1&" "&B1
or more specifically, depending on which "12:30" you want (AM or PM), ="13-06-2013 12:30AM" or ="13-06-2013 12:30PM"
Your data in column B may default to AM unless otherwise specified/imported differently, so you may need to tweak the data or to account for this.
Here is another approach to answering your question that uses a combination of MATCH, INDEX, and array operations to provide a compact formula solution that does not rely on helper columns.
I'll assume that your two columns of dates and times are in cells A2:B5, and the two date and time values that you want to look up are in cells A9:A10. Then the following two formulas will return what you require, the latest date and time values in your data that are less than or equal to the date and time that you are looking up. (The dollar signs in the formulas are hard on the eyes, but they are important if you will need to copy the formulas to other locations; for clarity, I omit them in the discussion that follows.)
DATE: =INDEX($A$2:$B$5,MATCH(A9+A10,$A$2:$A$5+$B$2:$B$5,1),1) --> 13-06-2013
TIME: =INDEX($A$2:$B$5,MATCH(A9+A10,$A$2:$A$5+$B$2:$B$5,1),2) --> 11:30 AM
These are array formulas and need to be entered with the Control-Shift-Enter key combination. (Of course, only the bits starting with the equal (=) sign and ending with the last parenthesis need to be entered into the worksheet.)
Things to consider:
The formulas assume that your data are valid Excel date and time values. Excel date values are whole numbers that count the number of days that have elapsed since January 1, 1900; Excel time values are decimal amounts between 0 and 1 that represent the fraction of 24 hours that a particular time represents. While your example data don't display AM or PM, I assume that their underlying values do have that information.
If your values are text (having been imported from another source, for instance), you should convert them to date/time values, if lucky, using only Excel's DATEVALUE and TIMEVALUE functions; if not so lucky, using some combination of Excel's string manipulation functions as well. (The values could be kept as strings, but you would almost certainly need to massage them so they would compare correctly "alphabetically" - much easier just to deal with Excel date/time values.)
If they are not already, your dates and times will need to be sorted from smallest to largest. (Your sample looks like they are sorted, and the formulas assume as much.)
How the formulas work
The basic idea behind the formulas is two-fold: first find the row in your data that holds the latest (largest) date and time that is still less than or equal to the date and time you are looking up. That row information can then be used to fetch the final result from each column of the data range (one for date and one for time).
Since both date and time figure in to what point in time is latest, the date and time components of both the value to be looked up and the values that will be searched must be combined somehow.
This can be achieved by simply adding the dates and times together. This does nothing more than what Excel does: an Excel date/time value has an integer part (the number of days since 1/1/1900) and a decimal part (the fraction of 24 hours that a particular time represents).
What is neat here is that the adding up of the dates and times - and the lookup of the particular date and time - can be done all at once, on the fly.
Take a look at the MATCH: The cells that contain the date and time to be looked up - A9 and A10 - are added together, and then this sum is matched against the sum of the date column (A2:A5) and the time column (B2:B5) - an operation that is possible of Excel's array arithmetic capabilities. The match returns a value of 2, indicating correctly that the date and time that fill your requirements are in row 2 of the data table.
DATE/TIME MATCH: = MATCH( A9+A10, A2:A5 + B2:B5, 1 ) --> 2
The 1 that is the final argument to the MATCH function is an instruction that the match results be calculated to be less than or equal to the value to be looked. It is the default value and is often omitted, or replaced with another value (for example, using a value of 0 will produce an exact match, if there is one).
(For readability, I've removed the dollar signs that are in the full formula; these anchor a range so that it remains the same even if the formula is copied to another location.)
Having figured out the row to look in, the rest of the formula is straightforward. The INDEX function returns the value in a data range that is at the intersection of a specified row and column. So, for the date in question, the formula reduces to:
DATE FETCH: = INDEX( A2:B5, 2, 1) --> 13-06-2013
In other words, INDEX is to return the value in the second row and first column of the data range A2:B5.
The formula for the time proceeds in exactly the same fashion, with the only difference that the value is returned from the second column of the data range.

Resources