I have a cell A1 with 00:40. I would like to write a formulae to recognise this as a hh:mm.
Apparently this formulae does not work: =if(A1="00:40",1,0). I get the result as 0, not 1. Is there anyway to get this excel formulae to return as 1?
I have other cells A2=00:42, A3=text, A4=00.50, A6=text, and A7=00.55. Is it possible to have a formulae to extract only the times and ignore the rest?
According to the comment you added on JDunkerley's answer, here is what you can try:
=MID(A1,FIND(":",A1)-2,5)
This will return some text.
Note that you could also use the TIMEVALUE function to convert this to a time (using LEFT and RIGHT to extract hours and minutes).
Try:
=If(TEXT(A1,"hh:mm")="00:40",1,0)
Simple fix, append +0 to the time
=if(A1="00:40"+0,1,0)
Put an apostrophe before the text.
Eg '00:40
In speadsheet formulae, you can use TIMEVALUE() :
IF(A1=TIMEVALUE("00:40"),1,0)
In VBA, just use the standard time separator: #:
If range("A1") = #00:40# then
Related
I need to count all dates that are "less than" today to see which work is overdue. I understand that this can be done simply with
=countif(F:F,"<"&TODAY())
However, the dates in Column F are formatted like "12/05 - Evening" instead of just "12/05". Because of this, the formula is not picking up anything. Does anyone know how to change this code so that it counts any cell that contains dates prior to today, even if there is other text in the cell? I've tried playing around with these "**", but can't get it to work.. Thank You!
So based on my comment I would get the date by using left() with find() like so:
LEFT(A1,FIND(" ",A1,1)-1)
Then format as short date and it behave as a date.
From comment:
Use a helper column and separate the date out then use the countif() on that column
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.
I am having trouble adding a zero after the decimal when coding in excel. The number that is being output is 240 and I want it to say 240.0. I have tried the round function in excel however that is only working when I have something like 242.46 and it gaves me 242.5.
Try:
oWrkSheet.Cells(110, 17).NumberFormat = "0.0"
It can work for many other numeric formats. See this post for more informations.
You can use a formula:
=TEXT(A1,"0.0")
Either change A1 to the appropriate cell, or surround the cell in question with a =TEXT(...,"0.0")
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.
I am looking to take the hyphen or dash out of a birthdate.
01/01/01
01-01-01
I need to combine the birthdate with other fields and it can't have the seperator in it.
I am sure there is a better way. I can get the month and year out, using left & right however I can't figure out how to get the middle out. Below is what I have so far and I know that I can combine them using "&"...if someone can help me with the middle or give me a better equation I would appreciate it.
LEFT(A1,2)
RIGHT(A1,2)
Solution:
=LEFT(F2,2)&MID(F2,4,2)&RIGHT(F2,4)
if it is a string, (not formated as a date) then you can use
MID(A1,4,2)
otherwise i just use the MONTH(A1) DAY(A1) YEAR(A1) functions
I'm not sure what an excel formula is so this answer might be irrelevant...
VBA has a Mid function that would do what you want I believe. This page has good explanations for that and the other similar functions: http://www.vbtutor.net/VBA/vba9.htm
You could also do a Find and Replace to replace the "-" with nothing.
Ctrl + H will bring up the Replace dialog box.
Change the number format of the date to something line "mmddyy". To combine it with other text in another cell, use a formula like:
="The date is "&TEXT(A1,"mmddyy")
where the date is in cell A1.