how to substract milliseconds (time with milliseconds as text) - excel

is there a way for me to make this
work?
the time is formated as TEXT

Create a new custom cell format. If you want to simply display the subtracted values as "0:00.500" (the value for the Column F cell outputting #VALUE), select General in the ribbon and then More Number Formats. Select the last option Custom to input the following in the Type field:
m:ss.000
This will allow for numerical values to calculate, so you can copy down your formula. If you want the cells to look exactly like the format you have in the last Column F rows (+0,000), use this custom type:
+_:s.000
(I am in the U.S., so I believe your cell will output with a comma in lieu of a period for the millisecond decimal point). FYI, cells with the regular Text format cannot be subtracted, added, etc. The format must be custom.

Related

Match function with dates

I have date column on two different sheets and when I run a match function (part of index match) it comes up N/A, because Excel says the two cells that have the same date in them are not equal to each other. When I change the format of one of the columns it changes to five numbers (which I know that is what excel uses to track dates), but the other column does not do this, it is simply text.
My question is, how to I get excel to forget about the five number date format and just give me text? Paste special values doesn't get it done like I thought it would.
I would say that you basically have two options: either convert both to text, or convert both to dates. If you want the text, the easiest way to convert them to text is via text to columns:
Select the column with the date (the one that turns to a 5 digit number when formatted to number or general) and select Text to Columns:
Click on next twice and select Text, then finish:
And that should do it.
I'll mention the other method, just in case, because in my experience, it's more often more practical to get the dates as actual dates in excel rather than text, especially when one wants to perform calculation on them or allow for different date formats.
The other method involves inserting 1 somewhere and copying it. Then select the set of dates that is plain text:
Use the paste special function and select 'Multiply' under the operations section:
All the dates normally should turn into those 5 digit numbers (if they were originally formatted as general for example). You simply then need to format them as date with the appropriate format, and your index/match should be fine matching the two date columns.
Excel will struggle to compare text (date as text) with numbers (date as an integer).
My suggestion is to convert the text into a 'proper' date. This is a good habit. When excel recognises something as a date it will store it as that 5-digit integer, but can display it however you choose (format cells to see the options)
So create a column next to your 'text dates'. Fill it with a formula which will create a 'proper' date, using the existing text.
If your text is in A1, then put this in B1. Assuming your data is dd/mm/yyyy
=date(right(a1,4),mid(a1,4,2),left(a1,2))
This is just saying that:
Year = rightmost 4 characters
Month= middle 2 digits (start at character 4 and grab 2 digits)
Day = leftmost 2 digits.
I assume you are using normal dates, and not the abomination that is USA format dates. But if your text is in USA data format then just swap the month and day parameters. Likewise if your text dates are 2 digits just tweak the 'year' parameter.
Check it works as expected, then copy down the column. You can now use column B for your vlookup or index match.
nb Jerry's answer is excellent and should work. I added the above because it tells you a little about how to directly work with dates. Good luck.

Converting month number from full date cell into text month in Excel

So I have a pretty long column with name dates and hours, like this:
14/01/2017 03:30
(They are DD/MM/YYYY HH:MM)
I need to get the month number and show it as text, like January, February, and so on.
If I format the destination cell as 'MMM' all the column cells show January even if the given month is 2, 3, or let's say 12. I also tried the formula =TEXT(L2,"mmmm") (since the given info come from column F.
Any ideas?
sounds like your date and time are stored as text and not in excels serial date format. You can test this by changing the format of the cell to general and seeing if anything happens if nothing changes then its text. another way would be to use the formula =istext(A1) where A1 is a cell with a date in it.
Now ASSUMING you do have dates in text format, I would suggest converting them to excels date serial. There are numerous ways of doing this. I will show you one way.
This will strip each component of the text out and then recombine it. We will assume your date in is A1
Strip out the year
=MID(A1,7,4)
Strip out the month
=MID(A1,4,2)
Strip out the day
=LEFT(A1,2)
Now to recombine it:
=DATE(MID(A1,7,4),MID(A1,4,2),LEFT(A1,2))
That will give you the date in an integer format that excel can then turn around and display as needed.
In order not to lose the time component you should strip that part off as well and combine it with the date. Remember the date is an integer, and the time is everything after the decimal. Think of time as a fraction of a day.
To get time out use:
=RIGHT(A1,5)
and to convert it to excel time:
=TIMEVALUE(RIGHT(A1,5))
and to get the two together, simply add:
=DATE(MID(A1,7,4),MID(A1,4,2),LEFT(A1,2)+TIMEVALUE(RIGHT(A1,5))
The key part to this whole thing is you will need to format that cell to display what you want. you can either choose a preformatted style from the drop down menu, or you can apply custom formatting. Setting the custom format to MMMM should display just the full name of the month.
IF you actually need the text of the month and not just the format, then you could use the formula from your question:
=TEXT(<insert appropriate formula from above>,"mmmm")
Try using MID to get the month only, then TEXT():
=TEXT(MID(A1,SEARCH("/",A1)+1,2),"MMMM")

Excel file has mixture of dates as text and serial numbers

I've gotten an Excel file in which some of the dates are actually serial dates (42741, 42800, etc.), and some are just text. Since the serial dates are formatted as dates, they all look alike, but Excel can't correctly sort them, and displays them as spanning a year instead of the two month period they actually represent.
To make things worse, the dates are formatted in the US style (mm/dd/yyyy), and my system uses the International (dd/mm/yyyy).
How do I clean this data!?
lets pretend your dates are in Column A place the following in an adjacent column and copy down accordingly.
=IF(ISNUMBER(A2),L7,DATE(RIGHT(A2,4),LEFT(A2,2),MID(A2,FIND("/",A2)+1,2)))
Alternative use TEXT to Column built in function in the ribbon.
1) Select your range of mixed dates
2) Select Text-to-Columns
3) Keep selecting next until you come to the page after selecting delimiters
4) Choose your destination location (default is overnighting your data)
5) Select the column header in the preview
6) Select the Date radio button for format
7) Select the date format that matches the source format
Serial dates will remain unchanged, and text dates will be converted.
After much grief, this is the method that worked for me. I hope it might help others!
Add a length column, containing =LEN(your date). The serial dates will have 5 characters, while the text ones will have 7. Sort by length.
Filter for the 5-length (serial) dates, and copy them to an adjacent
column.
Use the text-to-column feature on these cells. Separate by
delimited, under delimiters choose other, and type "/" (or ".", if
relevant). Hit finish.
In an adjacent column, use the DATE function to reconstitute your
date, month, year pairs into a date. (Note that if your year just
says, say, "17", Excel will assume it to be 1917, so either add the
leading "20" or hard-code it.)
Now, do a similar process with your 7-digit dates - copy them, split
by "/", (or "."), recombine into dates.
Copy your new dates back to their original slots and format them as
"Short date". Et voilĂ ! Excel now recognises them as dates. You can
sort and filter by actual date.

excel does not convert to date

when I donwload a data file it has date in this format(for example 20140701 which is actually 07/01/2014)
how can I make a macro do the conversion or is there a formula which takes this value and converts it into the corresponding date. actually I want to automate this and put it in the macro.
I have tried all solutions of almost similar cases on stackoverflow. but they don't seem to work.
This would be one way if the value was in A1... and assuming all dates in source are 8 characters in length in YYYYMMDD format.
=DATE(LEFT(A1,4),MID(A1,5,2),RIGHT(A1,2))
Date is a function accepting year, month day input and converting it to a valid date. Since we assume YYYYMMDD format, we can parse out the appropriate values using left, mid and right functions.
This formula could be used as part of a macro to insert a column fill in formula, fill down, then remove original column with YYYYMMDD format. (assuming you copy and paste as VALUES (since formula will not work after original values removed)

Convert Excel Text time to value

I have this format in an excel column:
00:03:30
It represents 3 minutes and 30 seconds.
I need to convert it to a numerical format where I can add them.
Is there a special kind of format I can use?
If the format is text then you can't change that by changing the formatting
Check whether the data is text by using this formula applied to one of the cells
=ISNUMBER(A2)
That will presumably give you FALSE
Assuming there are no additional characters in your data you can convert with "text to columns" - just select column of "times" then use
Data > Text to Columns > Finish
Now you should be able to sum and/or re-format the data

Resources