Convert date-time string to Date in excel - excel

I have two columns with date-time values such as "2019-08-15T00:45:28.228Z". I want to convert each of them into date format columns, and then find number of minutes between the dates.
eg:
| A1 | A2 | Date(A1) | Date(A2) | A2-A1 in minutes |
|--------------------------|--------------------------|----------|----------|------------------|
| 2019-08-15T00:45:28.228Z | 2019-08-15T00:55:28.228Z | | | 10 |
| 2019-07-25T00:45:45.127Z | 2019-07-25T01:25:55.127Z | | | 40 |
I have not been able to convert the columns into a date format, because it has a time element as well, and all online examples seem to be only for date

To get the data time all we need to do is remove the T and the Z so:
=--REPLACE(LEFT(A2,23),11,1," ")
Then format to the desired format.
Then a simple subtraction of the dates and a format of [mm] will return the desired output.

You can use LEFT function to retrieve the date (it will then be displayed in its original format, like 2019-08-15), or simply do --LEFT to convert the result to a number and change its formatting to Date using Excel:
Then use MID function to retrieve the times and do your A2-A1 calculation (format the last column as Time):
Update - as per Paul's suggestion, the length of the syntax will always be the same so you could use the following functions:
=--LEFT(A2,10)
=MID(A2,12,12)

Related

Conditional Formatting TODAY() with Date + Time in cell

What I am trying to do is highlight cells that contain both a date and time together, I would like it to ignore the time and highlight the cell if the date is equal to TODAY.
For example:
-| A | B |
1 | Option1 | 06/17/2020 0800 |
2 | Option2 | 06/17/2020 1500 |
3 | Option1 | 06/18/2020 2300 |
4 | Option1 | 06/20/2020 0800 |
I would want B1 and B2 highlighted if today was 06/17/2020.
I tried a few different formulas in conditional formatting I found on Google, but with no luck.
Thank you!
Use a rule based on the following formula:
=--(LEFT($B1,10))=TODAY()
Apply to column B.
Note that this assumes that the date portion is always in the format mm/dd/yyyy, i.e. it takes up the 10 left characters.

Ms excel - how do I add 1 day to my custom date?

I'm trying to add days consecutively across row 9 starting with Sunday.
In field e3 is the date for the beginning of the pay period in 6/24/17 format
In field c9 I have =TEXT(E3,"ddd, m/dd")
In d9 I have tried
=TEXT(E3,"ddd, m/dd")+1
=C9+1
And a few other ways but it returns "value"
How can I get the days in my custom format to auto grow in the custom format I have based on the original date in e3?
Don't use TEXT to format a date. Rather, right click on the cell(s), select Format Cells, Number, Custom, and enter your custom format there.
To increment dates, simply doing =dateCell + 1 works so long as that cell is a date; if it's not you're attempting to add 1 to a string; which doesn't make sense.
Example
Create a sheet with the following values/ formulae:
| A | B |
1 | Date | Formatted Date |
2 | 2017-06-24 | =A2 |
3 | =A2 + 1 | =B2 + 1 |
Leave column A's formatting as General; Excel will figure out that it's a date and will display it according to your local settings.
In column B, follow the steps above to format the cells as ddd, M/dd.
The result should look like this (column A's behaviour depending on your regional settings):
| A | B |
1 | Date | Formatted Date |
2 | 06/24/2017 | Wed, 6/24 |
3 | 06/25/2017 | Thu, 6/25 |

Excel: Average of parts of a column based on another column

Using Excel 2011 for mac, I have three columns: ID, Start date, end date and time to completion. (Date format: dd/mm/yyyy)
ID | Start | End | Time
1 | 01/01/2016 | 05/01/2016 | 4
2 | 04/01/2016 | 08/01/2016 | 4
3 | 01/02/2016 | 14/02/2016 | 13
4 | 02/02/2016 | 20/02/2016 | 18
5 | 01/03/2016 | 05/03/2016 | 4
6 | 06/03/2016 | 08/03/2016 | 2
7 | 12/03/2016 | 15/03/2016 | 3
Column D is basically the difference between column C and column B.
Now I have the total average, which is easy to calculate but I'd also like to have the averages for the different months.
And this is where my knowledge falls apart. I've tried several things but I can't seem to figure out how to calculate an average using only the cells in a column that match a certain value in another column. I could sort the tickets by date and do it manually by doing the average for only a certain range but as this list constantly changes this is definitely not a nice option.
Check out the AVERAGEIF function
AVERAGEIF(selection_range, criteria, averaging_range)
It uses the values in the selection_range to filter which values in the averaging_range will be averaged.
In your case you could say AVERAGEIF(B1:B8, "01/01/2016", D1:D8)
There are multiple ways. I would personally use an array formula, but that may be a bit advanced and overly complicated.
I suggest adding a column E "Month" - into E2 add:
=MONTH(B2)
Then copy cell E2 to E3:E8.
Now you can easily get a monthly average by applying the AVERAGEIF command:
=AVERAGEIF(E2:E8,2,D2:D8)
The second argument, 2, indicates February, but may be exchanged with any number from 1-12.

MAX date value within a range with 2 conditions

To make it easy
+---+----+-------------+
| | A | B |
+---+----+-------------+
| 1 | xx | 12-05-2015 |
| 2 | xx | 15-05-2015 |
| 3 | yy | 13-05-2015 |
| 4 | yy | 16-05-2015 |
+---+----+-------------+
(today is 14-05-2015)
I need to get the MAX date value for each "A" value only if it is before today.
In case it's not, move to the 2nd biggest value. Case it does not find, empty cell.
What I've done so far:
=MAX($A$1:$A$4='xx';$B$1:$B$4<TODAY();$B$1:$B$4)
and confirm with SHIFT+CTRL+ENTER
The error I get is that it yields 13-05-2015 as max value for xx, which is obviously wrong (as if it does not take into account the $A$1:$A$4='xx'
You need to use nested if-functions. I.e. change your formula into:
{=MAX(IF($A$1:$A$4="xx", IF($B$1:$B$4<TODAY(), $B$1:$B$4)))}
And end it with Ctrl+Shift+Enter
A standard (non-array) formula alternative.
=MAX(INDEX((B:B)*(A:A="xx")*(B:B<TODAY()), , ))
      
This formula would benefits from having its cell ranges cut down from full columns to something closer to the usable data range.
If your dates are sorted ascending as shown in the example then you can use LOOKUP like this:
=LOOKUP(2,1/(A$1:A$100="xx")/(B$1:B$100<TODAY()),B$1:B$100)
Doesn't require "array entry"

MS Excel - finding the first row after a certain date

Say I have a spreadsheet with the following, and for convenience say all of this starts from cell A1.
---------------------------------------
| Date | Item | Account |
---------------------------------------
| 01/09/2011 | Testing 1 | USD |
| 03/09/2011 | Testing 2 | USD |
| 11/09/2011 | Testing 3 | USD |
| 20/10/2011 | Testing 4 | JD |
| 22/10/2011 | Testing 5 | JD |
| 25/10/2011 | Testing 6 | USD |
| 03/11/2011 | Testing 7 | USD |
| 05/11/2011 | Testing 8 | JD |
---------------------------------------
Now, I want to run a report for a month, starting on 1/10/2011 and ending on 31/10/2011. I need to find the first row on or after the starting date, and then get every subsequent row until the end date. If I can figure out how to get the row reference for the first and end dates, then I can figure out the rows in between (obviously!).
I have only been able do these sorts of matches on exact matches ie. no idea how to do 'greater/less than' matches.
How would I go about matching on both the date and the account columns?
Needless to say, this needs to be in a formula.
=match(date(2011,10,1),a2:a9,1)+1
=match(date(2011,10,31),a2:a9,1)
First formula shows row for the first record for October, second formula for the last day. Data must be sorted in ascending order.
Use the following Array Formula for finding the Row containing the earliest date, which is equal to or greater than the date mentioned in cell C1 (in your case this is 1 October).
=MATCH(MIN(IF($A$1:$A$30>=C1,1,9999)*$A$1:$A$30),$A$1:$A$30,0)
Date list is in cells A1 to A30. Change the references as required.
Data need not be sorted in ascending or descending order.
Use the following Array Formula for finding the Row containing the latest date which is equal to or less than the date mentioned in cell D1 (in your case this is 31 October). Data need not be sorted in ascending or descending order.
=MATCH(MAX(IF($A$1:$A$30<=D1,1,0)*$A$1:$A$30),$A$1:$A$30,0)
If you want the earliest and latest dates, use the following Array Formulas.
=MIN(IF($A$1:$A$30>=C1,1,9999)*$A$1:$A$30)
=MAX(IF($A$1:$A$30<=D1,1,0)*$A$1:$A$30)
All the formulas used above are Array Formulas. To enter an array formula, use Control+Shift+Enter instead of Enter.
Vijaykumar Shetye, Goa, India
I would recommend using a pivot table for this. Look at the second link on in the "Excel Templates - Pivot Table" section on this page on the Contextures site.

Resources