Different date formats in Excel - excel

I have a csv that contains a list of dates, once imported into Excel they are in 2 different formats. How can I get them all in the same format?
Example:
01/23/2012
01/26/2012
40910
41031

You probably have a BIG issue with your file!
Probably, Excel is recognizing dates as "dd/mm/yyyy" but your data is "mm/dd/yyyy" formatted.
So, your numbers are really dates (just format, as #t.thielemans suggested). But are incorrectly parsed - month and day are switched!
Solution (assuming your dates are on A:A column):
To convert text to date:
=DATE(RIGHT(A1;4);LEFT(A1;2);MID(A1;4;2))
To correct day/month:
=DATE(YEAR(A1);DAY(A1);MONTH(A1))
Detect whether cell has date (dates are numbers, in Excel) or text:
=ISNUMBER(A1)
Finally, all combined within one formula:
=IF(ISNUMBER(A1);DATE(YEAR(A1);DAY(A1);MONTH(A1));DATE(RIGHT(A1;4);LEFT(A1;2);MID(A1;4;2)))
Just drag last formula from first row to end of your data and then format it as you wish (see #t.thielemans solution).

Select your data column and make sure they're highlighted. Go to Home>Number and select Custom and enter mm/dd/yyyy. You can also change the layout to one you want (mm-dd-yyyy/mmddyyyy/dd-mm-yyyy/...)

Related

Excel text to date format issue

I have the same issue as this OP when trying to change the date format
Excel 2010 date formatting not working on some cells but on others
The solution does work on converting those 'Text' to date format. However for the other datas in the same column which are in 'Date' format they give a #VALUE! error as shown in the image below when the entire column uses the formula.
Is there anyway to resolve this issue other than manually keying in the date which does not need to be fix, as I'm afraid in the future I might have more than a few thousands date to manually change
The formula I've used is this which the entire column uses,
=DATE(RIGHT(A2,4),LEFT(A2,FIND("/", A2,2)-1),MID(A2,FIND("/",A2)+1,2))
The data in column A is a mixture of text that looks like dates, and real dates. All rows with the error have the dates as real dates and the left/right/mid functions don't work on the format but on the underlying value, which in the case of the dates is a number. Try it just =RIGHT(A4,4) to see what I mean.
In order to run the formula, all data needs to be text. You can quickly convert the data to text by selecting column A, then click Data > Text to columns > Next > Next > Select "Text" in step 3 and click Finish.
The data will be converted to text and all your error values will disappear.

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 - Convert Date & Time to Date Format

I am working with a column of data which contains a date/time stamp of an event. The printed form is in US format, as follows:
12/25/2014 11:00 AM
The cells are formatted as "General". I'm looking to convert the column into a Date / Time field for ease of filtering and searching. Thus far the only way I've been able to convert the text is to use "Text to Columns" and import the columns delimited by a Space, but this hasn't gotten me exactly what I want as it imports the date perfect, but the time is still text and in another column, which isn't pretty.
Is there an easier way? Thanks in advance
Since these values are apparently text strings, you won't be able to change the values by formatting. Excel stores dates (and times) as days and fractions of a day since 1/1/1900. You have, I believe, four non-VBA options:
Change the data before you enter into your worksheet, to be in the same format as your Windows Regional Settings short date (perhaps DMY?)
Change your Windows Regional Settings short date format to match that of the data you are importing.
Split the data using Text to Columns as you have been, then combine the two fields with an addition. e.g.
Original data in A1
Split data in A1:B1
Combine -- C1: =A1+B1
Copy C1; PasteValues (C1), then delete A1:B1
Use a formula to separate the different segments. The following assumes your Windows Regional settings AM/PM designation is, indeed, AM/PM, otherwise the formula would have to also account for that. Also, if the format is mm/dd/yyyy hh:mm AM/PM then the formula could be simplified. The formula below assumes the format is m/d/yyyy h:mm AM/PM and that AM/PM works in your locale.
=DATE(
MID(A1,FIND("/",A1,4)+1,4),
LEFT(A1,FIND("/",A1)-1),
MID(A1,FIND("/",A1)+1,FIND("/",A1,4)-FIND("/",A1)-1)
)
+TRIM(MID(A1,FIND(":",A1)-2,9))
You should try custom formatting of date and time.
If working with Google spreadsheet see this link.
If working with excel see this link.

Extracting dates from a Microsoft Excel file when dates are in many different formats

I have been given an excel file with dates in a column for about 17000 rows. The problem here is that the dates are not reliable and the cells have varying formats. Some are formatted as plain text, some are in the "general" format, yet others are in one of several available date formats. In one case, I even found a date in a cell formatted as mm/dd/yyyy yet the date is showing up as 20/05/1989.
The only thing consistent about the dates is that they are actually date-first and month-second to the human reader, irrespective of whatever the format of the cell is. Another things is that the date separator isn't consistently used, some dates have the hyphen, some have the slash and yet others use the dot as the separator.
I intend to add another column next to the column with the dates, and have this column formatted as pure text. Now if I use the formula =TEXT() then this would of course give me the serial (excel) date.
Is there a way to get these dates as text, using VBA if necessary?
If I understand you correctly, you want to get a text version of what is displayed in the Excel sheet. Easy way to do this is save the sheet (or just the column in another sheet) as a Formatted Text (Space delimited)(*.prn) file. When you reopen the file, it will be treated as an importable text file.
Please try this formula across and advice.
=DAY(A1)&"-"&MONTH(A1)&"-"&YEAR(A1)
Regards
Shiva

Resources