Finding the difference in minutes or seconds for two timestamps in excel? - excel

I have two columns in a excel containing value like : Mon Dec 01 09:27:04 2014.
Lets say column A and column B and each column has rows containing values in the above format. How can we find the difference between two dates?
Mon Dec 01 09:27:04 2014 - Sun Nov 30 11:08:36 2014 = 25 hrs 51 minutes

Please see this for how to do that..
A more direct answer: you can format the cell
=TEXT(B2-A2,"h:mm")

I suspect the data is text strings for which I suggest:
=VALUE(MID(A1,9,2)&"/"&MID(A1,5,3)&"/"&RIGHT(A1,4))-VALUE(MID(B1,9,2)&"/"&MID(B1,5,3)&"/"&RIGHT(B1,4))+(MID(A1,12,8)-MID(B1,12,8))
However this relies on Excel's ability to interpret the likes of Dec as the month of December which may not be the case for all language versions. If so, I suggest a lookup table and extracting the dates with DATE along these lines:
=DATE(RIGHT(A1,4),VLOOKUP(MID(A1,5,3),Table,2,0),MID(A1,9,2))
However by such calculation the difference of the timestamps given in the question is:
22 hrs 18 minutes 28 seconds
when formatted:
[hh] "hrs" mm "minutes" ss "seconds"

Related

Calculate simple hours in MS Excel

How to calculate hours between 2 columns in MS Excel?
Sample data is: 04 Jan 2021 6:00:00:000PM and 04 Jan 2021 9:06:00:000AM
Thank you!
As a first step, I formatting the cells containing the date and time to mm/dd/yy h:mm.
Then I calculate the number of hours by converting the output to text "TEXT(J2-I2,"h")"

Remove ordinal date in Excel

Is there a way to remove ordinal dates in Excel?
4-Feb-19
4/02/2019
4 02 2019
4 February 19
04 February 19
04 Feb 2019
4th Feb 2019
4th February 2019
All the dates above are fine and can be picked up with cell formatting apart from the last two. Is there away to format the cell so the ordinals (st, nd, rd, th etc) are removed?
Something like
DD?? MMM YYYY
Where ? denotes an ordinal letter (wildcard) to be removed.
The alternative is to split the string, but that has its limitations just using formulas (which I'm limited to - macro free zone, here).
Scott suggested SUBSTITUTE, here's a possibility for you to try: The column needs to be text for this to work.
=DATEVALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"st",""),"nd",""),"rd",""),"th",""))

Filter dates by month in pivot table that doesn't start with the 1st of every month

Does anyone know how to filter dates by specific dates by month such as Jan 15 to February 15, Feb 15-March 15....etc on pivot table in excel?
My data is January 15 2017 to January 15 2018, so I like to filter it by specific dates but so far it's only letting me do the number of days which is not accurate since feb has only 28 days. thank you!

How to count running months of a specific year?

I'm currently struggling with calculating the running months depending on the year. I have the following table:
Received Month Received Year
Feb 2018
Feb 2018
Mar 2018
... ...
Nov 2018
Nov 2018
Dec 2018
Dec 2018
Jan 2019
Jan 2019
Feb 2019
I was using this formula to count the # of unique months (running months in 1 single cell [C1]);
=SUMPRODUCT(1/(COUNTIF(KAIZEN_Table[Received Month],KAIZEN_Table[Received Month])))
This was working great in 2018, it gave me 11 (Feb - Dec).
I have to add a filter that also checks if the year is 2019. I can't remove 2018 in the table because the operators are still using the 2018 lines. The filter is just here to set a KPI for 2019.
For some reason I can't figure out how to add the year. I tried;
=SUMPRODUCT(1/(COUNTIFS(KAIZEN_Table[Received Month],KAIZEN_Table[Received Month],KAIZEN_Table[Received Year], "2019")))
This is just giving me a 0.
Any suggestions on this? VBA code is also fine.
Edit: After extensive googling I found a working formula, for whoever might be interested in this.
=SUM(IF(FREQUENCY(IF(tbl[Year]=2019,MATCH(tbl[Month],tbl[Month],0)),ROW(tbl[Month])-ROW($L$5)+1),1))
L5 = First row of tbl[Month]
I have my data in A1:B14, the formula I've used is an array one
=SUM(1/(COUNTIFS($A$1:$A$14,$A$1:$A$14,$B$1:$B$14,$B$1:$B$14)))
however,
=SUMPRODUCT(1/(COUNTIFS($A$1:$A$14,$A$1:$A$14,$B$1:$B$14,$B$1:$B$14)))
would suffice
To do a particular year, you could do something like this
=SUM(($B$1:$B$14=2019)*(1/COUNTIFS($A$1:$A$14,$A$1:$A$14,$B$1:$B$14,B1:B14)))
Another approach is to use a Pivot Table.
On the Create Pivot Table dialog, select to Add this data to the Data Model
If you do this, you will note that one of the options in the Value Field Settings will be Distinct Count
Drag Received Year to the Rows Column; Received Month to the Values column, and select Distinct Count for the Value Field Setting

MS Excel: Fraction of date span within another date span

In Microsoft Excel 2007, given a date span, I want to find our what fraction of that date span lies within each season, which is obviously another date span.
For example:
Given a span of 26 Nov 10—28 Feb 11 (95 days):
26 Nov—30 Nov is in Spring (or Autumn for you Northerners) (5 days)
1 Dec—28 Feb in Summer (or Winter) (90 days)
Thus, 5.3% is in Spring/Autumn and 94.7% is in Summer/Winter.
Any Excel formula to work this out? Preferably not macro-dependent, but not a deal-breaker.
I would be difficult to explain in post. I have uploaded the solution at http://www.2shared.com/file/WHU5v_h1/Book1.html Let me know if you have questions...

Resources