I am working in software. From that I got out put as .CSV format file. Now I need to convert that .CSV file in to Excel 2007 and then I have to use that file. In that I have Previous Month date and Current month date. For example I am working for May month means the date is 13/05/2013 this is the standard format, but in some cells I found the format changed to 3/5/2013 (05-Mar-13) But it should be 5/3/2013.
How to change this - any formula or formatting?
Instead of double-clicking on the .csv file try Data > Get External Data - From Text, Import and at Step 3 of 3 format Date to suit.
Edit Attempt at clarification
I am a little confused by the OP’s comment here (it is not working when coupled with the green tick) and not quite sure whether DMY or MDY is required output but given the source as in ColumnA, then importing with DMY gives ColumnB (after formatting) and with MDY gives ColumnC (after formatting). Both Columns B and C in General format appear as numbers (B5 as 41338 and C5 as 412397 – vice versa in Row6).
If say 1/4/13 is April 1st and 1/5/13 is 5th January then I see no solution given the data presently available. The normal problem is where Excel has a default setting such that 6/7/13 converts to July 6th for a date that is supposed to be June 7th, because the same setting can’t cope with 10/21/13 (there is no ‘month 21’). Hence some dates are left as strings, some converted (incorrectly) and only some correctly (1/1, 2/2 etc are no problem).
Related
I have used a previous version of Excel and OpenOffice Calc, and I was able to format dates to the Ukrainian format "dd.mm.yy" so that when I typed for example "1.8" in the cell marked with this format, it correctly read it as "01.08.22" (the first of August of the current year). Now I'm using the newest Excel and for some reason when I type in "26.08", it autocompletes as "26.01.00" with the following in the formula section: "1/26/1900 12:14:24 AM". Now I could understand not filling in the year I want it to, but not even the month?
And when I do fill it in fully, I don't think it recognizes the text as a date at all! The dates filled in previously in the same document are interpreted and formatted correctly, but not the new ones. The format is identical, I formatted the whole range of cells together.
Typing "8/26" gives me the desired date, but it's not my regional format and it's inconvenient to use.
Is there a way to make Excel do what I want, here?
I am trying to open a CSV file which contains a column named ts which has timestamp in the following pattern throughout the file:
12/31/2016 20:40
mm/dd/yyyy hh:mm
Now when I open this in Excel, some of them are getting recognized some not.
The problem seems to be that Excel is automatically recognising it in dd/mm/yyyy hh:mm format so when a date is 11/13/2016 0:00, it is unable to recognise it(because of 13th Month).
How to fix this?
You'll find that even when Excel is recognizing dates, it's getting the months and days back to front.
When opening a .csv file directly (e.g. by double clicking it from Windows Explorer or choosing File > Open from within Excel), Excel will try to parse any dates according to your local time format. The only way to change how dates are parsed when opening a file directly is to change your local time format, which you probably don't want to do.
The workaround is to open the file from within Excel using the Text Import Wizard, where you can explicitly state the format in which dates have been stored in the text file.
Open a new workbook
Go to the Data tab; in the Get External Data group, click From Text
Select your file and click Import
Step 1: Choose Delimited and select Next
Step 2: If it's a true .csv, choose Comma as your only delimiter. (Note that quite often, data exported from other systems is tab-delimited rather than comma separated. However, the .csv file extension is still used to indicate that the file is opened in Excel (or similar). If choosing Comma isn't splitting your columns correctly, try choosing Tab as your delimiter instead. When your data has been split into columns correctly, press Next.)
Step 3: Select the column that has dates, then set the Column data format to Date and in the drop down, choose MDY. It should look like this:
Click Finish
Choose where you want the data to go and click OK
You should now have the data open, with the dates correctly interpreted and also displaying in your local date format (dd/mm/yyyy).
If you want to keep the full date and time in one column, then additional work is required because there's no way of telling Excel to correctly interpret a date/time string that doesn't match your local format.
Start by following the above steps, but at step 6, choose Text as the data format instead. This is necessary to ensure Excel doesn't try to interpret any dates (where day is less than 12).
Then, if your dates are always in mm/dd/yyyy hh:mm format (including leading zeroes for single digit days, months and hours), then the following formula will convert a date/time string that is in cell A1 to a date/time serial that you can format and work with as normal:
=DATE(MID(A1,7,4),LEFT(A1,2),MID(A1,4,2)) + TIMEVALUE(RIGHT(A1,5))
This is happening because the output date you got is in text format, not in date format. Here is the trick to resolve your case to get the output in mm/dd/yyyy hh:mm format. You can change the format to your desired one.
If text date is in A column, then formula is -
=DATE(MID(A3,SEARCH("/",$A3,SEARCH("/",$A3,1)+1)+1,4),LEFT(A3,SEARCH("/",A3,1)-1),MID($A3,SEARCH("/",$A3,1)+1,SEARCH("/",$A3,SEARCH("/",$A3,1)+1)-SEARCH("/",$A3,1)-1))+TIME(HOUR(RIGHT(A3,LEN(A3)-SEARCH(" ",A3,1))),MINUTE(RIGHT(A3,LEN(A3)-SEARCH(" ",A3,1))),SECOND(RIGHT(A3,LEN(A3)-SEARCH(" ",A3,1))))
Hope this helps. Rate if satisfied. :)
I've left the Text Import Wizard approach as a separate answer, because it has some useful info. However, I've realized that if we're heading down the path of needing to use a formula, then we might as well just use a formula after opening the file normally!
The following formula works on all date/times that were stored as mm/dd/yyyy hh:mm
=IF(ISNUMBER(A1),DATE(YEAR(A1),DAY(A1),MONTH(A1))+A1-INT(A1),DATE(MID(A1,7,4),LEFT(A1,2),MID(A1,4,2)) + TIMEVALUE(RIGHT(A1,5)))
The formula first checks whether Excel has interpreted the value as a date, which happens when the day is less than or equal to 12. If it has, then Excel has swapped day and month, so the formula swaps them back. Alternatively, if Excel hasn't interpreted the value as a date (which happens when the day is greater than 12), it will still be text and a date/time is generated after rearranging the text string.
So my friend has this template he got from his boss, it's got a bunch of dates and times and other data. He told me he created a new workbook and copied everything from the template to this new workbook and then he modified the dates. The date and time listing he copied from another file.
So this is where the problem occurs, when he's done copying, one entire column resulted with #VALUE! instead of expected result w/c would be in yy/ww format. The formula is written below:
=MID(N2,9,2)&"/"&IF(LEN(WEEKNUM(N2,1))=1,"0"&(WEEKNUM(N2,1)),(WEEKNUM(N2,1)))
Inside N2 is 26/08/2014 1:27 PM. So I googled a bit and found out that WEEKNUM doesn't work for text-style date and time. Should only work with serial numbers, if I understand it correct. I checked the N column (which was all copied from another file) and they were all in text. But when I checked the template, the dates were also all in text style. So how the formula worked with the template but not with the new workbook? (I'm assuming that every text in every cell is aligned to the left, dates in both new workbook and the template are both aligned to the left.)
I told my friend that the N column should be in date format so I suggested him this formula:
=(DATE(2014,8,26) + TIME(13,27,0))
And finally it worked. But his and my concern would be that we can no longer just copy and paste the dates but manually input every date within the formula. But there's just too many dates and it would take a long time to finish.
Any way around this?
UPDATE:
I just noticed something. The format of the dates copied is dd/mm/yyy h:mm AM/PM. When I checked on the column where all the #VALUE!s are spawning, there are exceptions. I actually found 3-4 cells that are normal.
The date is: 02/10/2014 3:49 PM and the result with using the formula is 15/49. I'm wondering, could it have been with how the dates are typed in? Or rather copied in? Like, should the date format be in mm/dd/yyyy instead of dd/mm/yyyy?
Used evaluate formula and it said that N2 contains a constant.
The WEEKNUM function works with dates as text while it can implicitly convert the text to date. Example:
Input '31/03/2015in A1 and =WEEKNUM(A1) in B1. Input '03/31/2015 in A2 and =WEEKNUM(A2) in B2. Note the leading ' before the dates. They will convert the inputs to text. One of them will work, one will not. This will indicate which is your default date format dd/mm/yyyy or mm/dd/yyyy.
You say both Excel are English but there is a difference in default date format between GB English and US English unfortunately.
So if the dates are text in dd/mm/yyyy format and your default date format is mm/dd/yyyy, you can't simply copy them into your Excel and work with them. You have to change them ever to mm/dd/yyyy first. Ever, because even the values which seems to work are mostly wrong. WEEKNUM with the text 09/11/2015 will work even with default date format mm/dd/yyyy. But it will implicitly convert the text to September 11. 2015 while with dd/mm/yyyy 09. November 2015 was meant.
Best solution ist not to use dates in text format. If your friend's boss had used date values instead of text then copy&paste would work. But because he had not, you have to convert the formats in a helper column now. Try
=MID(N2,4,2)&"/"&LEFT(N2,2)&"/"&MID(N2,7,999)
copied down in a helper column.
I have following numbers, which actually represent dates in the YYYYMM format:
201301
201302
201303
...
When I try to format the cells to date fields, Excel always overwrites the original dates and creates some crazy dates, that have nothing in common with the actual ones.
How can I bring Excel to convert it properly?
Excel (by default) uses the 1900 date system. This simply means that the date 1 Jan 1900 has a true numeric value of 1, 2 Jan 1900 has a value of 2 etc. These values are called "serial values" in Excel and it is these serial values that allows us to use dates in calculations. which was discussed here.
So that explains why your data reflects a different date when you try to format is as Date.
What you need to do then is to transform it into a complete readable date format Excel recognize.
As is, Excel will use its default Serial Value conversion.
If you have your data in starting in A1, enter this in B1.
=DATEVALUE(SUBSTITUTE(A1,LEFT(A1,4),LEFT(A1,4)&"-")&"-01")
Above formula will then create a valid Date that Excel can interpret and read correctly.
Result will be:
41275
41306
41334
When you format it as Date, it will equate to the 1st day of every month.
1/1/2013
2/1/2013
3/1/2013
You can just fix the formatting using Custom Format to get YYYYMM as seen below:
If your range is small enough (in the example all 2013) then no formula is required. Replace 13 with 13-, apply Text to Columns with Tab as the delimiter and at Step 3 choose Date and YMD.
You can use the DATE and LEFT/RIGHT functions.
Assuming that format is consistent (i.e. 4 characters for year, 2 characters for month), to convert cell A1:
=DATE(LEFT(A1,4), RIGHT(A1,2), 1)
This will assume the first day of the month for the date (I assume that's irrelevant for you). You can then format the cell as you want.
Can you use formula in Excel to solve this..
A sample formula is given below
=DATE(MID(CELLID,1,4),MID(CELLID,5,2), 1)
Here is a list of dates:
04-22-11
12-19-11
11-04-11
12-08-11
09-27-11
09-27-11
04-01-11
When you copy this list in Excel, some of them are recognized as dates, others not, in the following manner:
04-22-11
12-19-11
11-04-11 (date)
12-08-11 (date)
09-27-11
09-27-11
04-01-11 (date)
Does anyone know why? And how to force Excel to recognize all list items as dates?
Many thanks!
It is caused by Excel auto-recognizing/formatting the cell contents, but in unclear/inconsistent ways.
Fixing it is not that hard...
Check out this forum post:
http://www.pcreview.co.uk/forums/excel-not-recognizing-dates-dates-t3139469.html
The steps in short:
Select only the column of "dates"
Click Data > Text to Columns
Click Next
Click Next
In step 3 of the wizard, check "Date" under Col data format, then
choose: "DMY" from the droplist.
Click Finish
This is caused by the regional settings of your computer.
When you paste data into excel it is only a bunch of strings (not dates).
Excel has some logic in it to recognize your current data formats as well as a few similar date formats or obvious date formats where it can assume it is a date. When it is able to match your pasted in data to a valid date then it will format it as a date in the cell it is in.
Your specific example is due to your list of dates is formatted as "m/d/yy" which is US format. it pastes correctly in my excel because I have my regional setting set to "US English" (even though I'm Canadian :) )
If you system is set to Canadian English/French format then it will expect "d/m/yy" format and not recognize any date where the month is > 13.
The best way to import data, that contains dates, into excel is to copy it in this format.
2011-04-22
2011-12-19
2011-11-04
2011-12-08
2011-09-27
2011-09-27
2011-04-01
Which is "yyyy-MM-dd", this format is recognized the same way on every computer I have ever seen (is often refered to as ODBC format or Standard format) where the units are always from greatest to least weight ("yyyy-MM-dd HH:mm:ss.fff") another side effect is it will sort correctly as a string.
To avoid swaping your regional settings back and forth you may consider writting a macro in excel to paste the data in. a simple popup format and some basic logic to reformat the dates would not be too difficult.
In your case it is probably taking them in DD-MM-YY format, not MM-DD-YY.
The quickest and easiest way to fix this is to do a find and replace on your date seperator, with the same separator.
For example in this case Find "-" and Replace with "-", not sure why this works but you will find all dates are right-aligned as they should be after doing this.
Here is what worked for me. I highlighted the column with all my dates. Under the Data tab, I selected 'text to columns' and selected the 'Delimited' box, I hit next and finish. Although it didn't seem like anything changed, Excel now read the column as dates and I was able to sort by dates.
The simplest solution is to put yy,mm,dd into the date() formula by first extracting them with left(), mid() and right(). In this case, assuming your input date is in A1:
=date(right(A1,2)+100,left(A1,2),mid(A1,4,2))
Explanation of above:
=right(A1,2) gets the last two digits in the cell (yy). We add 100 because it defaults to 1911 instead 2011 (omit +100 if it doesn't do that on yours)
=left(A1,2) gets the first two digits in the cell (mm).
=mid(A1,4,2) gets 2 digits in the middle of the cell, starting at 4th digit (dd).
Why this happens in the first place:
I come across this problem all the time when I import Canadian bank data into excel. In short, your input date format does not match your regional settings.
Seems your setting mean Excel wants date input as either DD-MM-YY or YY-MM-DD, but your input data is formatted as MM-DD-YY.
So, excel sees your days as months and vice-versa, which means any date with day below 12 will be recognized as a date, BUT THE WRONG DATE (month and day reversed) and any date with day above 12 won't be recognized as a date at all, because Excel sees the day as a 13th+ month.
Unfortunately, you can't just change the formatting, because Excel has already locked those day/month assignments in place, and you just end up moving what Excel THINKS are days and months around visually, not reassigning them.
Frankly, it is surprising to me there is not a date-reverse tool in excel, because I would think this happens all the time. But the formula above does it pretty simply.
NOTE: if your dates don't have leading zeros (i.e. 4/8/11 vs 04/08/12) it gets trickier because you have to extract different amounts of digits depending on the date (i.e. 4/9/11 vs 4/10/11). You then have to build a couple if statements in your formula. Gross.
Here is what worked for me on a mm/dd/yyyy format:
=DATE(VALUE(RIGHT(A1,4)),VALUE(LEFT(A1,2)),VALUE(MID(A1,4,2)))
Convert the cell with the formula to date format and drag the formula down.
Right-click on the column header and select Format Cells, the chose Date and select the desired date format. Those that are not recognized are ambiguous, and as such not interpreted as anything but that is resolved after applying formatting to the column. Note that for me, in Excel 2002 SP3, the dates given above are automatically and correctly interpreted as dates when pasting.
A workaround for this problem consists in temporarily changing your regional settings, so the date format of the CSV imported file "matches" the regional settings one.
Open Office seems to work in a similar way for that issue, see: http://www.oooforum.org/forum/viewtopic.phtml?t=85898
I come across this problem when I tried to convert to Australian date format in excel. I split the cell with delimiter and used the following code from split cells then altered the issue areas.
=date(dd,mm,yy)