I have dates within a cell using this format: (February 13 2014).
When I try to use "WEEKDAY(C2)" I get #VALUE!
I have no idea how to fix this and I need some help to finish this web scraping project. Any ideas?
The problem is that the date is a string, and not a real Excel date formatted as you show. The WEEKDAY function needs have a "real Excel date" as its argument, not a string.
If the apparent spaces between the date components are spaces, then the following formula should work:
=WEEKDAY(--SUBSTITUTE(C5," ",", ",2))
EDIT: As David Zemens just pointed out, the double unary seems to be unnecessary with the weekday function. So
=WEEKDAY(SUBSTITUTE(C5," ",", ",2))
should be a better solution.
If they are something else, the formula would be different, but the principal would be similar
Another method: You may be able to convert it to a "real date" by using the Text to columns wizard, but DON't split it on anything. (You can do that by selecting something like TAB as the delimiter; since there are not tabs, no splitting). When you get to step 3, merely check that it is a date in MDY format. That wizard is pretty smart. Then you can use the WEEKDAY function directly.
One way to do so... maybe not best since it involves adding so many rows
Add a fresh column D and E if not available..
Then use Text to Columns on Column C, with space as delimiter... (This will split column on spaces into 3 columns)
Add a new Column D with formula
=MONTH(C3&1)
Make sure new Column D is of type General or Number rather than Date
Then you can use the following formula
=DATE(F3,D3,E3)
Formula only:
=WEEKDAY(DATE(RIGHT(C2,4),MONTH(LEFT(C2,FIND(" ",C2)-1)&1),(MID(C2,FIND(" ",C2)+1,2))))
with thanks to #tgeery.
Your dates are not in the correct format.
WEEKDAY(DATE(2014,2,13))
should work because the argument for the weekday function needs to come from the DATE function.
Related
I have a excel file with one column as project assignments. A sample value of this column is given below :
XXX E(10aug15-30sep16),YYY G(30nov15-29jul16),ZZZZ C(18jan16-23dec16),AAA B(04jan16-28jul16)
You can see, each assignment has start date and end date. The end date can be identified using ')' bracket, i.e. 7 character before ')' bracket.
I have to write a formula to give me max of all end dates identified. I know, I can use Macros, but due to security issues, our organization wants to avoid macros.
The output of above field should be 23-Dec-2016.
Please suggest.
Assuming that, for a given string (in A1):
1) The format of each end date within that string is precisely ddmmmyy
2) The entry immediately preceding each closing parenthesis is never anything other than an end date
then, array formula**:
=MAX(0+MID(A1,MODE.MULT(IF(MID(A1,ROW(INDEX(A:A,1):INDEX(A:A,LEN(A1))),1)={")",")"},ROW(INDEX(A:A,1):INDEX(A:A,LEN(A1)))))-7,7))
Format the cell containing this formula as you wish, e.g. to Custom type ddmmmyy.
Note that this solution may require a small amendment if you are using an Excel version for which the row- and column- separator in array constants are not, respectively, the semicolon and comma.
Regards
**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
Assuming your start date is always greater than your end date, you simply need the greatest date, Which you can find using the following formula:
For a string like this in cell A1
XXX E(10aug15-30sep16),YYY G(30nov15-29jul16),ZZZZ C(18jan16-23dec16),AAA B(04jan16-28jul16)
Use the formula:
=MAX(IFERROR(VALUE(MID(A1,ROW($A$1:$A$1000),7)),0))
Enter it as an array formula - using Ctrl+Shift+Enter
Notice the following piece of code:
ROW($A$1:$A$1000)
This sets the max string length to be 1000 - make this more or less depending on what you think you'll need. The less the better as excel won't need to work as hard. I would suggest 200 might be more than enough based on your example string.
Not very flexible but it works so long as you have 4 end dates without departing from the given format. Can't think of any other way to do it apart from VBA which would be ideal.
=TEXT(MAX(MID(A1,FIND("-",A1,1)+1,7),MID(A1,FIND("-",A1,FIND("-",A1,1)+1)+1,7),MID(A1,FIND("-",A1,FIND("-",A1,FIND("-",A1,1)+1)+1)+1,7),MID(A1,FIND("-",A1,FIND("-",A1,FIND("-",A1,FIND("-",A1,1)+1)+1)+1)+1,7)),"ddmmmyy")
Use MID to extract data between the brackets. Suppose your data is in A column, you can use formula:
=MID(A2,FIND("(",A2)+1,FIND(")",A2)-FIND("(",A2)-1)
You'll get your hyphen-separated start and end dates (like this: 10aug15-30sep16).
Now use LEFT, RIGHT and SEARCH to fetch you start and end dates:
Start Date:
=LEFT(B2,SEARCH("-",B2)-1)
End Date:
=RIGHT(B2,LEN(B2)-SEARCH("-",B2))
To Convert these dates as text, use TEXT as follows:
=TEXT(D2,"ddmmmyy")
Hope I have included all the formulae you may need for your report.
My data is extracted from an application and it has a text that looks like a date/time in excel. How do I actually convert "3/24/2016 11:22:07 PM" (in text) to a real date/time conversion? I've tried formatting the cells but it doesn't work.
For a date conversion:
=DATEVALUE(TEXT(A1,"MM/DD/YYYY"))
For a time conversion:
=TIMEVALUE(TEXT(A1,"HH:MM:SS"))
For datetime conversion:
=DATEVALUE(TEXT(A1,"MM/DD/YYYY"))+TIMEVALUE(TEXT(A1,"HH:MM:SS"))
Where A1 has the data you wish to convert.
By the way, then you may wish to format the cell to a date/time or whatever.
Hope that helps.
1) try using the DATEVALUE function and see if that works for you.
2) A more reliable way, since datevalue does not always work is to strip the text out manually and insert it into and excel date value. You are going to want to use a combination of the following functions:
DATE
TIME
IF
FIND
MID
LEFT
RIGHT
LEN
Now in my opinion the easiest way to do this is to work with multiple helper columns to build out all the steps. One column per step. When you get your final answer, you can substitute or copy paste your formulas from the helper columns into the final formula until you are left with one variable. The reason I say this is that the final formula referring to only 1 variable gets rather lengthy/ugly and very hard to trouble shoot if you make a typo, forget a bracket or something goes wrong. When I did this approach I used a totally of 14 columns (includes final formula). When I packed it all up into 1 formula it resulted in this:
DATE(RIGHT(LEFT(A3,FIND(" ",A3)-1),4),LEFT(LEFT(A3,FIND(" ",A3)-1),FIND("/",LEFT(A3,FIND(" ",A3)-1))-1),MID(LEFT(A3,FIND(" ",A3)-1),FIND("/",LEFT(A3,FIND(" ",A3)-1))+1,FIND("/",LEFT(A3,FIND(" ",A3)-1),FIND("/",LEFT(A3,FIND(" ",A3)-1))+1)-FIND("/",LEFT(A3,FIND(" ",A3)-1))-1))+TIME(LEFT(RIGHT(A3,LEN(A3)-FIND(" ",A3)),FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)))-1)+IF(AND(LEFT(RIGHT(A3,LEN(A3)-FIND(" ",A3)),FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)))-1)<12,RIGHT(RIGHT(A3,LEN(A3)-FIND(" ",A3)),2)="AM"),0,12),MID(RIGHT(A3,LEN(A3)-FIND(" ",A3)),FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)))+1,FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)),FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)))+1)-FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)))-1),MID(RIGHT(A3,LEN(A3)-FIND(" ",A3)),FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)),FIND(":",RIGHT(A3,LEN(A3)-FIND(" ",A3)))+1)+1,2))
Note it is set up using cell A3 as the one with the time as text that needs formatting.
3) You should also be able to use excel's text to column function located on the DATA ribbon about half way across.
4) And of course there will be a way to code it through VBA as an option as well.
=DATEVALUE(A1)+TIMEVALUE(A1) seems to work as well, since each function only returns the value corresponding to what it recognizes in the string. That is, DATEVALUE() ignores the time component, while TIMEVALUE() ignores the date component.
Three columns below, I'm attempting to use column C as a formula that checks against a hard coded date.
8/18/14 12/19/20 formula
In column C =IF(AND("10/7/15">=A1,"10/7/15"<=B1),"IN","OUT")
What I'm looking for is to tell if 10/7/15 is between 8/18/14 & 12/19/20 - I would expect that to come back with a value of IN but it doesn't.... hoping its something simple I'm missing
I think the problem is you're comparing a date (which translates to a number) to a text string. It's a crap-shoot as to what Excel will do in this case. If you compare a date to a date, I believe you will get the desired behavior:
=IF(AND(DATE(2015,10,7)>=A1,DATE(2015,10,7)<=B1),"IN","OUT")
The datevalue function should also work.
If you really have a date in A1, you can try:
=IF(AND(VALUE("2015-10-07")>=VALUE(A1),VALUE("2015-10-07")<=VALUE(B1)),"IN","OUT")
I am simply importing CSV into Excel, In which I have a date column. it seem like this.
10.22.2014 13:34:00
When I am finish Importing Now I want to convet the whole date column to look like this in the format cell section but it is not working for me. Can you suggest another way. What can be the main reason SUppose i put a formula on the column then Everytime user import the data he need formula which might be not a good idea, Is there something I can do when I m importing or just like wondering what could be done?
10/22/2014 1:34:00 AM or PM
Here's one approach:
Substitute dots with slashes
Use DATEVALUE, TIMEVALUE functions on relevant subsections of this substituted string. Subsections are fetched using LEFT and RIGHT string functions.
These return a serial number for dates (days since 1900) and time (a floating point between 0 and 1). When summed, the value can be represented as both date and time, in a format of your choice, as shown below:
Or, showing formulas:
EDIT: adding all-in-one formula.
Note that this will give you the serial value (41934.5652777778), which can then be formated using the built in formats for dates / times--just select the one you want. This does not actually render a string:
=DATEVALUE(LEFT(SUBSTITUTE(A1,".","/"),10))+TIMEVALUE(RIGHT(SUBSTITUTE(A1,".","/"),8))
If, however, you do want a string returned, you can use the TEXT function.
=TEXT(DATEVALUE(LEFT(SUBSTITUTE(A1,".","/"),10))+TIMEVALUE(RIGHT(SUBSTITUTE(A1,".","/"),8)),"m/d/yyyy h:mm AM/PM")
(This is done in libreoffice, but the same formulas and arguments exist in MS Excel)
Is there a way to add a leading zero to a date that is 7 digits and should be 8?
7301982 should be 07301982.
I have a column full of these values, and need a way to do so with a formula. Any ideas?
I know this is an oldie, but when I googled for a solution this was the first result.
What I did was:
=concatenate(year(A1),text(month(A1),"00"),text(day(A1),"00"))
Where A1 is a date field.
=text(A1, "00000000") will do it.
Set a custom format of 00000000
Just another thought since this just happened on my new laptop. It could be your windows settings. If you prefer leading zeroes on the month everywhere in windows (like the lower right hand clock) then you can:
Control Panel >> Clock, etc >> Change Date, Time or Number Formats... then set the Short Date to MM/dd/yyyy.
This also carries over to Excel as the first date format. I know it is not a formula exactly as asked, but this is the article I found while searching.
Simply go to custom for the format of the number and select yyyy\m\d and add more m or d to it.
This is a good formula when you need leading zeros so another application sees a 9 digit number.
Add a column to your spreadsheet (Column B if your data is in Column A)
Use this formula in the new column: =REPT(0,9-LEN(A2))&A2&""
Get the 1st cell, then drag down as much as you need.
Remember to copy/paste option 123 to save as data. Otherwise, you'll see data but in reality it is a formula and you will receive reference errors if you try to use the data in column B.
9 digits and column B are variables. You can use any length or any column on your spreadsheet. Just adjust the formula.
Copied from another answer on a different site, worked for my like a charm!
ok. It seems that your dates are formatted as text. This is what you should do.
first, on a blank cell somewhere on the sheet, type the number 1. then, right click, copy.
next, highlight the entire column of dates. right click, paste special, multiply.
all of the dates will have turned into numbers.
next, highlight the date column, and apply the date format that you want.
There is a simple way to maintain the leading zeroes in Excel.
Simply add this to the cell and type whatever value you need and the zeroes will be retained
For ex: If I want 0000000023
Type into a cell '0000000023
That ' symbol seems to retain the zeroes as long as you type it before the values.
This date format MM/DD/YYYY is available if you select the Locale (location): English (Philippines). Try it with one cell and then copy/paste/special/formats the others.