Excel won't wort mixed dates - excel

I downloaded a file from a government source. There is a column of dates in mixed formats. Some appeared 12-25-99 while others were 25-Dec-99 and some were 12/25/99. I want to sort them newest to oldest. There are over 600,000 records but I tried everything on a sample of about 25 to save time.
I managed by brute force to get them all looking the same: 12/25/99. There is nothing I can do to get them to sort. Some of the list sort because they were all the same format to start with, generally 12-25-99 though it might have been 25-12-99. No matter. The ones that had slashes never integrated with the ones that started out with dashes.
I found 6 or 7 ideas on this site but none of them worked. Help if you think you can.
Thanks.

The data samples you list suggest that what you perceive as "dates" is at least partly text. Excel internally stores dates as numbers, with day values before and time values after the decimal point (or decimal comma, depending on your regional settings). These numbers can now be formatted to appear as dates.
To check which of the "dates" are really dates, select them all and change the format to "General". Any real dates will now show as numbers, whereas any "dates" that are really just text, will remain unchanged.
In order to sort this data chronologically, you will need to convert the text values to real dates.
There are several different approaches you could use for that. You could use a formula like DateValue() - this works well with text that has the date and month in the same order as your regional settings. So, if you use US settings with MDY order of a date, give that a try.
Otherwise, and especially if the original dates are a mix of DMY and MDY order, you will need to use more sophisticated data cleanup techniques, like Text To Columns or Power Query.

Related

Change the Excel date input format?

I've been struggling with Excel (2016) date formats. I know how to change display formats for dates and cells but the problem I have is the input format for dates. If I input a date as "DD.MM" or "DD.MM.YYYY" it does recognize it as a date but if I input the date as "DD.MM." (with the second dot after the month), Excel does not recognize it as a date anymore. The column in question is formatted as short date.
Is there anything that can be done or is this by-design? If so, it seems really strange as at least in my country it's the official way to write the date containing that second dot after the month number when there is no year included in the date.
I've been searching and Googling for solution but couldn't find anything on this really. I appreciate all comments and help regarding this question!
SUMMARY/TL;DR:
Excel version is 2016, country is Finland and language is finnish
Excel accepts/recognizes these as dates: 12.5 or 30.8
Excel does NOT accept/recognize these as dates: 12.5. or 30.8.
The column in question is formatted as short date
The dot after the month seems to be screwing things up
Why is this happening? Can anything be done?
Kind regards,
Tenttu
Yes, it is/was by design. (Funny enough, my Excel won't allow dots, only dashes (-), so I couldn't even test if "15.8" works)
So, there's a slight chance that the language of Excel (the defaults of time (24 hours or AM/PM), dates (MM/DD or DD/MM), decimals (comma or dot) etc.) wouldn't allow the dot at after the month. Here's an example of a user that has that dot, and wants to get rid of it. So, your system language is a good candidate for why this wouldn't work for you.
However, I realize that the example linked above don't feature a date with a dot at the end. Which could suggest it is rather by design. For example, if I add a dot to a valid date or time, it will result in some #VALUE!-error. And that's because of how Excel is programmed to convert text to a date - and remember, dates are actually just really large numbers. So, adding a dot at the end makes that conversion "impossible". We might think it's as easy as to remove a dot, but in programming, we need to program that explicitly to do that, and I'm leaning towards there is no such operation done during text to date conversion (certainly not on my system, as I get #VALUE!).
One work-around is to strip the ending dot from the date to make it a valid date. So, you can import sheets with dates with dots at the end, then strip them away, and you'll be good to go!

Problems with Date Filtering in Excel

I am running an Advanced Filter on an excel data set from FRED. I've been trying to filter the data to include only January, April, July and October data (first month of each quarter). If I run an advanced filter with the criteria as a specific date (ex. 1/1/1995), the result returns as expected. However, as soon as I use any special search characters, (ex. 1/, 1//*, 1995 or 1/1/????) I get no results. I've read the excel documentation, and searched the internet for solutions but no one seems to be having this issue.
Ideally what I want to do is search for all of those months while excluding everything else (something like 1* OR 2* OR 3* or 4*) the first thing I need to figure out is why I can't seem to make filtering work period.
I'm guessing that the issue has something to do with how excel treats dates. Originally the dates were in the format DD-MM-YYYY but I realized that Excel was processing them as if they were in M-D-YYYY format so I changed the data to reflect that. I tried transforming the dates into regular text to get around that but Excel converted them to numbers that looked like "4/1/1995."
Keep in mind I am new to filtering so I'm probably making a rookie mistake.
Sample of Data and Criteria (Filter not applied)
observation_date FEDFUNDS
1*
observation_date FEDFUNDS
1/1/1995 5.53
2/1/1995 5.92
3/1/1995 5.98
4/1/1995 6.05
5/1/1995 6.01
6/1/1995 6.00
7/1/1995 5.85
8/1/1995 5.74
Wildcards only work on strings. Dates are not strings, but are numbers. So you need to use greater than and less than to set bounds in which to return numbers, as I have done below for the month of February. (Note that my dates are in non-US format)
Here is a picture showing a working example with the filtering criteria followed by the filtered data and the advanced filter window with the ranges used in my case. From A2 to A5 is the dates I want the advanced filter to work on.
Filtering by part of a date (the way you see it in the cell) would not be possible with FILTER as far as I know.
Your feedback/ comment is appreciated!

How to convert two time formats into one?

I am pulling Cross Country race times, and trying to convert the race time into an integer that can be easier to work with.
I am using the formula
=([Cell Name]-INT([Cell Name])*60*24
But I am so far retrieving two different time formats:
17:23.4
15:09
Both formats take that formula differently, and they are producing different numbers. The first format is changed into 17 minutes, but the other is turned into 1000+ minutes. Is there a way that I can convert these times into one format?
The main problem you are having is as tom sharpe pointed out is that some times are being assessed as HH:MM and others as MM:SS. if you look at your source data cell (assmue A2) and use the following formula it will tell you if you are dealing with text or time in excel serial date time formatted to appear in a manner we are used to seeing:
=ISTEXT(A2)
now assuming that the result is TRUE, this means you are dealing with TEXT. Adding a leading 0: to the text will make the time recognizable to excel as being in the format HH:MM:SS and allow for you to deal with it consistently.
To do this use the following formula:
=timevalue("0:"&A2)
Things may get a little wonky if ou have anything greater than or equal to 60 as the first two digits.
once you have it in the proper format you can then use it in your formula.

Wrong format of a cell in Excel

I am copying large tables from a website to Excel and it is copied in a wrong format. The number which I need seems to be in a cell but when I click into the cell it shows me that it is a date (and the number shown in the cell is its month and year).
Is it possible to change that so that the number in the cell will be 4.25 instead of 1.4.2025?
Thanks a lot.
You can change the format by highlighting the cells, right clicking selecting the format cells option. It will not change the string of numbers from 1.4.2025, but you will be able to replace the date format with something more appropriate for your needs. *
In the 1900 date system, 1.12 and 12.15 (for example) if entered as 1/12 and 12/15 respectively (where the locale has . as the decimal separator) into cells formatted General will show 01-Dec and Dec-15 respectively. The underlying number however (ie change format from Custom to Number) is 42339 for both. 42339 in Short Date format shows as 01/12/2015.
Although generally possible to deduce what malformed number gave rise to what looks like a date it is not always possible to do so. Ambiguity is greatest where the digits for the decimal or integer parts are less than 13. In addition, the locale in which the numbers were entered may play a part (since, in the 1900 date system, 3/4 for example would be interpreted as 42097 where the date convention is DMY 'UK' and 42067 where the date convention is MDY 'US').
So the answer to your question:
Is it possible to change that so that the number in the cell will be 4.25 instead of 1.4.2025?
is "Yes, but not fully reliably" (and even so would require knowledge or guessing of locale, date system and time of the conversion). Since you are "copying large tables from a website to Excel" it seem you retain access to the source data and I would recommend returning to that. On a small scale manual adjustments may be viable, on a large scale consider importing first to software without such automatic interpretation (eg Word, NotePad++) or, if possible, as character separated values imported as text. Address the delimiters with string handling there and only after that import to Excel or save in Excel format.

Joining a date and time into a single cell in Excel / VBA

I have to report basically the same information from inspections to two different clients, both of whom have provided me with an Excel spreadsheet in their own preferred format, and password protected. I have put the two sheets into my own workbook, and have managed to get 'almost' all the data on both sheets to populate from my own data. Where I am stuck though is on the time logs.
Client 'A' has each time and date in a single column, in the format "12.29.12 14:30". Client 'B' has two columns, date as "12/29/12" in the first, and time as "1430" in the second.
I'm trying to avoid having to type all the same dates and times twice - it can be several dozen lines - both to save effort and to avoid errors. What I really need to do is either concatenate the date and time from client 'B's report and put it into client 'A's, or split the date and time up in 'A's so I can put it ito 'B's. I've tried several approaches, but just end up with error codes or meaningless numbers.
Can anyone point me in the right direction?
Thanks,
Richard
Never mind... the very next thing I tried worked :-)
To anyone else reading this, the trick is not to concatentate the date and time values, but to add them together.
Richard
As you later pointed out in your own question, in order to manipulate date/times in Excel, you should add instead of concatenating.
The reason for this is that Excel stores all date/times as a number representing the number of days since January 1, 1900*. This number is stored as a 8-byte double.
Use Excel number formats to display the date/time format that you desire.
If you find in a worksheet that some cell's dates are in fact stored as text, use the DATEVALUE function.
*By default, Excel 2010 for Windows uses the number of days since 1900. There is an option to use the number of days since 1904 for compatibility with other versions.

Resources