What formula to use in Excel when trying to process dates - excel

I have a Excel database and I have three columns. One is "holiday start date" and the other is "holiday end date" and "Available?" what I want to do is basically create a formula to see when the person is on holiday, the Available box will show Yes or No. The formula needs to recognise the date and only say that this person is not available if the holiday is within today to a fixed time. Anything else to become available.
I have tried over and over to try and get this formula but can't seem to get it to work here is my attempt so far.
=IF(AND(AE9(DATE<=2/9/14),AE9(DATE<3/9/14),AF9(DATE>3/9/14)),"GOOD","BAD")

I am assuming you have the date effective in some cell. I am assuming this to be today for simplicity. If it is not, you simply have to replace today() with the cell number that has value for date effective!
I am also assuming the following headers on the following Cells.
AE1 : Holiday Start Date
AF1 : Holiday End Date
=Today() : Gives the current date. Should be replaced with the date to be tested for!
if(or(not(and(Today()<af9,today()>ae9)),today()<ae9,today()>af9,"no","yes")
or simply
if(and(today()>af9,today()<ae9),"yes","no")

Related

Deleting cell data when it is a specific date

If A1 contained the number 5 and A2 contain the date 7/1/23 when we reached the date of 7/1/23 I want to delete the number 5 in cell A1. Can anyone assist with a simple formula for this? Thank you!
Hey there!
What you want to do within the same cell as the value 5 may require some more skilled coding that allows the cell to hold data and a formula that updates itself. However I can recommend another way that achieves what you want but also retains some history.
The left set is what your result would look like if the date is older than todays date. The right being if todays date has not reached the date you specified.
Before row contains the points that would currently exist, while after would contain the points after the date affects the "drop off" you would like.
Then an If statement just compares whether todays date is older/same/or newer than the target date. (To make this formula more dynamic, you can replace B5 with "today()")
=IF(B5>=B3,"",B1)
or
=IF(TODAY()>=B3,"",B1)
Hope this helps!
What it should look like:

Extract date out of cell with date and time

I have a cell G4 with date and time in a format (Text string):
1/29/2020 1:34:24 PM
I need to convert it to DATE formatted cell. How to do that?
I have tried to get numbers and convert them to DATE with this formula:
=DATE((MID(G4;SEARCH("/";G4)+4;SEARCH("/";G4;SEARCH("/";G4)+1)-SEARCH("/";G4)+2));(MID(G4;SEARCH("/";G4)+1;SEARCH("/";G4;SEARCH("/";G4)+1)-SEARCH("/";G4)-1));(LEFT(G4;FIND("/";G4;1)-1)))
So:
I am extracting year:
=MID(G4;SEARCH("/";G4)+4;SEARCH("/";G4;SEARCH("/";G4)+1)-SEARCH("/";G4)+2)
Month
=MID(G4;SEARCH("/";G4)+1;SEARCH("/";G4;SEARCH("/";G4)+1)-SEARCH("/";G4)-1)
Day
=LEFT(G4;FIND("/";G4;1)-1)
I am getting as a result:
1.5.2022
I need it as it is now, but output should be 29.1.2020 in this case. Later I want to get day difference two that way formatted dates. Is it possible to do it with formula without performing any other cell formatting operations?
EDIT:
I got it working, the only problem is:
How to extract number (year) after third "/"? My current formula is not correct:
=MID(G4;SEARCH("/";G4)+4;SEARCH("/";G4;SEARCH("/";G4)+1)-SEARCH("/";G4)+2)
It does not function correct in this case:
2/5/2020 12:21:05 PM
EDIT:
I did it this way (I also had to minus G2 - F2, to get days difference):
=IFERROR(DAYS(MID(G2;SEARCH("/";G2)+1;SEARCH("/";G2;SEARCH("/";G2)+1)-SEARCH("/";G2)-1)&"."&LEFT(G2;FIND("/";G2;1)-1)&"."&MID(G2;FIND("/";G2;FIND("/";G2)+1)+1;4);MID(F2;SEARCH("/";F2)+1;SEARCH("/";F2;SEARCH("/";F2)+1)-SEARCH("/";F2)-1)&"."&LEFT(F2;FIND("/";F2;1)-1)&"."&MID(F2;FIND("/";F2;FIND("/";F2)+1)+1;4));"")
You probably need to replace an order of day.month.year and "." to "/" if you are using different date setting (region). I have one setup, so this seems to work.
FYI DATES in excel are stored as integers. They represent the number of days since 1900/01/01 with that date being 1. TIME is stored as a decimal representing fractions of a day or 24 hours. 0.5 represents noon. 24:00 is not an officially supported time in excel, but will work with some functions.
The DATE Formula is looking for three arguments representing YEAR, MONTH, DAY in that order.
DATE(Year, Month, Day)
You need to pull the text from your string representing these values. I find it easiest to pull each one individually in its own cell to ensure the part of the formula is working first then copy and past that part into the DATE formula so the whole calculation in the end can be performed in one cell.
YEAR
To get the year use the following formula:
MID(G4,FIND("/",G4,FIND("/",G4)+1)+1,4)
MONTH
To get the month use the following formula:
LEFT(G4,FIND("/",G4)-1)
DAY
To get the day use the following formula:
MID(G4,FIND("/",G4)+1,FIND("/",G4,FIND("/",G4)+1)-FIND("/",G4)
COMBINED FORMULA
Place the above formulas into the date formula as follows:
=DATE(MID(G4,FIND("/",G4,FIND("/",G4)+1)+1,4),LEFT(G4,FIND("/",G4)-1),MID(G4,FIND("/",G4)+1,FIND("/",G4,FIND("/",G4)+1)-FIND("/",G4)-1))
Note the only cell reference in the formula is G4. The results of the formula are not in an Excel Date format. Change the formatting of your cell to meet your needs. In your case I would apply a custom cell format of d.m.yyyy
If you have TEXTJOIN,
=TEXTJOIN("/",TRUE,INDEX(FILTERXML("<a>,<b>"&SUBSTITUTE(SUBSTITUTE(TEXT(A1,"dd/mm/yyyy hh:mm:ss"),"/","</b><b>")," ","</b>",1)&"</a>","//b"),N(IF({1},{2,1,3}))))
Depending on your version it may need to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
the reason the second did not work is that Excel actually changed it to a date and a date is a double, not text. So there are no / in the data. so we need to force back to the incorrect string.
Those for whom the TEXTJOIN function is not available can use this:
=DATE(FILTERXML("<DATA><A>" & SUBSTITUTE(SUBSTITUTE(A1;"/";"</A><A>");" ";"</A><A>") & "</A></DATA>";"/DATA/A[3]");FILTERXML("<DATA><A>" & SUBSTITUTE(SUBSTITUTE(A1;"/";"</A><A>");" ";"</A><A>") & "</A></DATA>";"/DATA/A[1]");FILTERXML("<DATA><A>" & SUBSTITUTE(SUBSTITUTE(A1;"/";"</A><A>");" ";"</A><A>") & "</A></DATA>";"/DATA/A[2]"))

IF Function Query - Extended

I got an answer for a previous question regarding an IF function on my excel tracking sheet.
I would like to further this by adding another formula to the existing formula.
I am looking for some help regarding an IF function on an Excel
document.
Basically if the Date Listed cell is dated over 1 month ago (eg: Date
Listed 6-Aug but today is 6-Sep) and the Date Sold cell is blank, then
I would like the Mark Down cell to say 'MARK DOWN', which at the
moment it does but it is only 10-Aug today.
If the Date Listed cell and the Date Sold cell both contain dates I
would like the Mark Down cell to say 'OK'.
So far I have this written:
=IF(AND(DATE(YEAR(G2),MONTH(G2),DAY(G2)), ISBLANK(H2)),"MARK DOWN","OK")
I know I'm not far off but I need help sorting out the
last parts..
Bonus if you can help me add a highlighted cell formatting to it :)!
Example Image
******Original formula:
=IF(AND((TODAY()-G11)>31,ISBLANK(H11)),"Mark Down","No")******
My additional query is:
If this item hadn't been uploaded yet, therefore there would be no date in the Date Listed cell, I would like to have an ISBLANK function which returns with "Not Required".
I have read something about ampersands and joining functions but not sure how to use them properly.
Here is what I have so far:
=IF(AND((TODAY()-G19)>31,ISBLANK(H19)),"Mark Down","No"), OR(ISBLANK(G19)),"Not Required")
Thanks again.

Using the 'TODAY' function

My spreadsheet is to show me how many days active a certain field has been.
For this I am trying to find a formula which will automatically take the entered date from one cell and deduct it from "todays" date.
As an example I have used =DATEVALUE("22/04/2017")-TODAY() - and although this works, i am unable to drag the formula down into other cells, to auto populate when a date has been entered/ amended. I'm having to enter the formula above every time, and if the date changes, as an example from the 22/04/2017 to the 20/04/2017, I would have to manually amend the formula too. How can I get it just pick up the date in that particular cell and deduct "today" from it?
Sorry if i'm rambling, I just don't know if I'm explaining myself properly.
Thank you
Typically, 'how many days active a certain field has been' would be a positive number (i.e. the number of days). Reverse the subtrahend and minuend to get a positive integer like this,
=today()-a3
To avoid getting 5/15/2017 or 42,870 as the result when A3 is blank, check to see if there is something in A3 before attempting subtraction.
=if(len(a3), today()-a3, text(,))

Microsoft Excel, =TODAY() through a condition displays strange number instead of date

I am not sure if I am just over looking something, because I am still a very newbie to Excel's functions, so here comes the problem :
Lets say that I have A1 cell, and I want to display todays date in another cell whenever the A1 cell isn't empty.
So I came with this :
in another cell :
IF(A1<>"";TODAY();"")
Todays date is 16.8.2015, but when I run TODAY() through a condition like this, the output is : 42232
Why would I get this weird number ?
Maybe I did syntax wrong ? Not sure.. I also tried to make =TODAY() in new cell, that displayed the 16.8.2015, and then I wanted to show that cell through that condition, it threw the "42232" again.
Be sure that the cell format is Date and not General or Number.
The TODAY function returns a serial number which is equivalent to the amount of days since 1/1/1900. That is why you are seeing the number instead of the date.
Select the cell with the number and on the Home tab you can change the format to Date (See Below).
Every date in Excel is represented by a number. For example, the number 1 represents 1/1/1900. Whereas 42232 represents 8/16/2015.

Resources