any excel formula to subtract cells separated by comma (textjoin etc etc)
example:
A1 has this data (10/01/2021,20/03/2021)
A2 has this data (15/01/2021,26/03/2021)
I want to subtract A2-A1 which is (15/01/2021-10/01/2021,26/03/2021-20/03/2021)
output would be (5,6)
Note A1 and A2 might not have equal set of dates. A1 might have only two dates, A2 might have only two or four etc etc and vice-versa. Ideally first date of A2 should should be subtracted from first date of A1 and so on)
If your dates are always entered with this format, you can do it with this silly thing;
=CONCATENATE(LEFT(RIGHT($A$2,LEN($A$2)-1),10)-LEFT(RIGHT($A$1,LEN($A$1)-1),10),",",(RIGHT(LEFT($A$2,LEN($A$2)-1),10)-RIGHT(LEFT($A$1,LEN($A$1)-1),10)))
I had to change the date formatting to MM/DD/YYYY because my system is set to United States and it wasn't working the with DD/MM/YYYY.
But, VBA would probably be more reliable.
EDIT: Sorry missed the part where you said dates may not always have only two dates. You could do it but its just a long sting of garbage that it would just be better to work in VBA.
Related
I'm simply trying to find the number of hours between the two dates and times, but excel won't account the date to the number of hours, and only calculates the 'hours' themselves.
Your format on cell B3 is wrong. You may have mistakenly copied the date format from the cells above to B3.
If you set your format to "General" on cell B3 and change the formula to
=ABS(B1-B2)*24
I think you'll get the result you're looking for.
Just wondering how can I change different formats of dates and then calculate the number of days between the two.
I have one date in the format
2016-04-01 00:06:13:313
And another in the format
06/05/2016 00:00:00
Just want to find out how many days are between the two dates.
Many thanks
If you attempt to re-format the data and the displayed values do not change, then the values are probably Text rather than numbers formatted as dates.
If this is the case, with the values in A1 and A2, in B1 enter:
=DATEVALUE(LEFT(A1,10))+TIMEVALUE(MID(A1,13,8))+RIGHT(A1,3)/(86400000)
and in B2 enter:
=DATEVALUE(LEFT(A2,10))+TIMEVALUE(MID(A2,13,8))
Then format the B cells:
In another cell, enter:
=B2-B1
I'd like to assign dates to cells in a planner spreadsheet I have made.
Currently, the rows are months, the columns are days of the week, and each individual cells just have a number for the day of the month.
I don't want to display the full date in the cell, just have the cell "know" what date it is representing. One use of this could be to have the current day always highlighted in a different colour when opening the spreadsheet. Is this possible in Excel?
Looking at your question, the results would require to show multiple "dates" within the cell.
For January '16 for example, you would have 4 different type of dates as January has 4 Mondays (4;11;18;25). Is this what you're looking to achieve? Otherwise it is not possible to have excel figure out a single date unless you provide it with additional references in order to come up with a result.
Enter a date into a cell. Format the cell to show the part of the date you want to see. In the screenshot, column A contains full dates in each cell. A2 and down are formatted with the custom format code shown in column C
Excel still treats the dates as the underlying full dates in formulas, even though only parts of the dates are showing in the cell.
I have around 20,000 records in an Excel file and around four columns which have dates. I am trying to insert those into SQL. However date columns have dates in incorrect format eg; 02/092015 or 02/90/2015 or 2015. So checking 20,000 records one by one would be very lengthy.
I tried to count / but it didn't work. It changes the format of column to date.
I was looking for some formula which can check the format and maybe color the cell or something like it.
I was running across this issue today, and would like to add on to what nekomatic started.
Before we begin, the TEXT formula needs to follow the date format we are working with. If your dates are in month/day/year format, then your second argument for the TEXT formula would be "mm/dd/yyyy". If it is in the format day/month/year, then the formula would need to use "dd/mm/yyyy". For the purposes of my answer here, I am going to have my dates in month/day/year format.
Now, let's assume that cell A1 contains the value 12/1/2015, cell A2 contains the value monkey, and cell A3 contains the value 2015. Further, let's assume our minimum acceptable date is December 1st, 2000.
In column B, we will enter the formula
=IF(ISERROR(DATEVALUE(TEXT(A1,"mm/dd/yyyy"))),"not a date",IF(A1 >=DATEVALUE(TEXT("01/01/2000","mm/dd/yyyy")),A1,"not a valid date"))
The above formula will validate correct dates, test against non-date values, incomplete dates, and date values outside of an acceptable minimal value.
Our results in column B should then show 12/1/2015, not a date, and not a valid date.
Two of the examples you give are text which may be identified with Conditional Formatting by applying a formula rule such as:
=ISTEXT(A1)
and colouring the result as you wish. There would be an issue if all your dates (even those of valid format) are also text but I'm guessing that is not the case.
For the third example (ie 2015) a CF formula rule such as:
=AND(A1<2500,A1>0)
may help.
If your columns are a mixture of what should be dates and other entries that are properly text strings your approach may be better than the more general ISTEXT, for example a CF formula rule of:
=FIND("/",A1)>0
If you can add a column to the Excel sheet with the formula
=DATEVALUE(TEXT(A1,"dd/mm/yyyy"))
this should return #VALUE if the contents of A1 are not a valid date in dd/mm/yyyy format. You can filter on this value to identify the incorrect records.
Edit: If A1 contains only 2015 this formula returns 07/07/1905 (if the formula cell is formatted as date) so you can spot these by filtering for dates before the earliest correct date your file should contain.
In Excel I have three columns, say A, B and C, all with the background format of hh:mm:ss and the 1904 date system, meaning that I can do simple arithmetic across the columns.
Cells in columns A and B will mostly be populated with times but can also be either blank or have text in them.
Using cells A1, B1 and C1 as an example I need a formula in C1 which says if both A1 and B1 have times within them then perform the sum A1 minus B1 into C1. So if A1 is 01:07:26 and B1 is 01:08:26 the resultant sum in C1 will be -00:01:00. If blank or text appears in A1 and/or B1 then the arithmetic function will not be performed.
I have been going round in circles with SUMIFS and have not managed to figure out a formula which will do the trick so if anyone could help me I would be very grateful.
I don't have Excel on this machine, but a more fruitful approach would
be something like:
=IF(AND(ISNUM(A1),ISNUM(A2)),A1-B1,"")
If you need more fine-grained checking for a time, see this post.