Excel doesn't recognize a time column so I'm unable to parse the hour from it using =HOUR().
I've tried formatting the column of datetimes (formatted dd/mm/yyyy HH:MM) as date and time using Excel formatting, and also tried pulling the datevalue using =DATEVALUE(), but always end up with a #VALUE! error.
time hour ("=HOUR(A2)")
29/05/2018 16:20 #VALUE!
29/05/2018 16:25 #VALUE!
29/05/2018 16:30 #VALUE!
I would expect if the cells are formatted properly then the hour (16) should be returned, but instead it is just the #VALUE! error, so there must be some formatting issue, but I can't figure out what it is or how to fix it.
Your values are Text rather than true date/times. Use:
=--MID(A1,12,2)
instead:
In the event you have 8:10 instead of 08:10, you can use this to capture just the hour:
=--TRIM(MID(A1,SEARCH(" ",A1),SEARCH(":",A1)-SEARCH(" ",A1)))
Your values are text, and it is likely that your windows regional settings are MDY.
Best solution:
Go back to the source and convert properly when importing into Excel. Especially if you are importing a text or csv file.
Possible solution if ALL of your values are text:
Use Data Text-toColumns wizard.
Split between the date and the time
For the date column, select DMY for the format
If some of the values are text, and others real dates, then you will have to convert the text values to dates first, and not alter the real date values. Best way: see "best" solution, but we'd need more information.
Related
Hi I know lots of similar questions can be found here, but I am still facing this problem:
I have a table with one column called Dates with some values shown below:
12/2/2021
11/2/2021
10/2/2021
9/2/2021
8/2/2021
7/2/2021
6/2/2021
5/2/2021
4/2/2021
3/2/2021
2/2/2021
1/2/2021
31/01/21
30/01/21
When I try to convert it using Format cells either by selecting category as Date or adding custom category as dd/mm/yy, excel treat the dd/mm/YYYY values as mm/dd/yy.
So for example, instead of treating 1st row as 12 February, excel thinks of it as 2 December.
I also tried convert text to columns by going to DATA and setting it as DMY but it doesn't solve the problem.
Any help is really appreciated.
Try this formula:
= DATE( YEAR(A1), DAY(A1), MONTH(A1) )
If the values have any space character, try this one:
= DATE( YEAR(TRIM(A1)), DAY(TRIM(A1)), MONTH(TRIM(A1)) )
Assumptions:
All the dates were originally DMY
Your windows regional settings short date format is MDY
You will need to convert to a proper date
If the value is text, then it will be in DMY format and you can extract the sections and convert to a date
If the value is numeric, then it has been converted improperly and you need to reverse the month and day part
Given those assumptions, the following formula should work.
I am using the LET and FILTERXML functions which are available in Excel Office 365 Windows versions.
If you don't have that version of Excel, you can still do this with formulas but it will be more complex. Or you can use VBA.
=IFERROR(DATE(YEAR(A1),DAY(A1),MONTH(A1)),
LET(x,FILTERXML("<t><s>" & SUBSTITUTE(A1,"/","</s><s>")& "</s></t>","//s"),
DATE(INDEX(x,3)+IF(INDEX(x,3)<30,2000),INDEX(x,2),INDEX(x,1))))
I am kind of struggling with dates in Excel. So, here is the case:
I have dates in Column AP in text format as I imported the same from a CSV. All the dates are suppose be DD-MM-YYYY HH:MM:SS.
Using the formula =DATEVALUE(TEXT(AP2,"DD-MM-YYYY")) + TIMEVALUE (TEXT(AP2,"HH:MM:SS")) I have been able to convert most of the dates. However, for certain dates like "13-06-2018 00:08:42" or "15-06-2018 00:10:11", the mentioned formula doesn't work. I am getting #VALUE!
Need help.. Thanks..
Since you're getting #VALUE! when the first field is greater than 12, I surmise that your formula is mixing up the month and date fields. One brute-force way to get the dates is:
=DATE(MID(AP2,7,4),MID(AP2,4,2),MID(AP2,1,2))+TIME(MID(AP2,12,2),MID(AP2,15,2),MID(AP2,18,2))
Hope that helps
I have a date field where the format is (example) 20170101.
When I try to convert this field to short date, it comes up as "###".
I need the date in the format of 1/1/2017.
Can someone help?
Thanks!
The data is not a date but a number and by simply changing the format will try to return a date that is 20,170,101 days from 1/1/1900. And Excel stops recognizing dates after 12/31/9999. This would be well beyond that, roughly 45 thousand years beyond that.
you can use a helper column with the following formula:
=--REPLACE(REPLACE(A1,7,0,"/"),5,0,"/")
Format it as desired.
Then you can copy paste just the value over the original.
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.
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)