Telling whether a date is before a particular time in excel - excel

I have a spreadsheet with a date column in Column A. I want to have a column where it returns TRUE if the date is before September 2016. How do I do that?
I tried this code in Excel but it wouldn't work.
=if(A1="2017","TRUE",if(month(F1)<"September,"FALSE","TRUE"))
Can anyone help me correcting this one? Thanks

I'm assuming Column A has the actual dates (ex: 3/3/2017). So your if statement (if<"September") is trying to compare text against a date, which will give you an error.
Easiest way to do this is enter 9/30/2016 in a separate cell (for this example, say Q1). Then in your formula, simply use:=A1 < $Q$1 and drag that down. It should give you T/F for the dates.

If Column A is formatted as a date, it has to be compared with a date only. If not excel will give you unexpected results.
The DATE function in excel allows you to input data in date format with Years, Months and Days. The format is below,
=DATE(Years,Months,Days)
You can try the below formula,
=A1<DATE(2016,9,30)
and drag it down throughout the range.

Related

Formula to calculate DATE as TEXT

I have searched online and in forums but can´t find any solution for this.
I want to calculate date as TEXT in Sharepoint list with calculated fields.
It works to calculate well with the formula below, but it prints the date like this "2018-07-06T22:00:00Z"
=IF(ISBLANK([Contract Start]);"";DATE(YEAR([Contract Start]);MONTH([Contract Start])+[ContractLength];DAY([Contract Start])))
I have tried the following formula, and it gives me the date in the format i wish "2018-07-06" but i can´t get it to add months from column [ContractLength] to the date.
=IF(ISBLANK([ContractStarts]);””;CONCATENATE(TEXT([ContractStarts];"yyyy");"-";TEXT([ContractStarts];"MM");"-";TEXT([ContractStarts];"dd")))
So I need help with a formula that adds the specified number of months from the [ContractLength] column to the start date [ContractStarts] column in the SharePoint list, and print it as TEXT so we get the date printed "2018-07-06".
Thanks in advance!
I'm not quite sure what you mean with "calculate date as text". If you mean you want to show the result as text, not a date, then you can use this formula.
=IF(ISBLANK(ContractStarts);"";TEXT(DATE(YEAR(ContractStarts);MONTH(ContractStarts)+ContractLength;DAY(ContractStarts));"yyyy-mm-dd"))
Or, if you want the result to be a date, then this formula works fine, too, but you need to select "Date" as the data type of the calculated column and tick the button for Date only.
=IF(ISBLANK(ContractStarts);"",DATE(YEAR(ContractStarts);MONTH(ContractStarts)+ContractLength;DAY(ContractStarts)))
The screenshot below shows both formulas at work in the SharePoint list.

Excel proper date format in Excel

I have worksheet named as Correlation_Process and it contains the field of Birthdate and Age.
what i want to do is to get the age based on the birthdate i already get the age based on the birthdate using excel formula. but some of the rows returns some error like this #VALUE!
Here's my excel formula to get the age: =DATEDIF(A:A,NOW(),"y")
and Here's my date format (Month/day/year) i dont get the error shown in picture which is #VALUE! when some of the rows are showing the expected output
anyone can help?
=DATEDIF(A:A,NOW(),"y")
The formula entered into cell B2 should be this:
=DATEDIF(A2, NOW(), "y")
Copy this formula down the B column and you should have the data you want.
The general formula for DATEDIF is
DATEDIF(first_date, second_date, UNIT)
Why dont you try something like this:
=TEXT(TODAY();"yyyy")-TEXT(A2;"yyyy")
And see if it works
OK lets go back to basics and the sure fired way to snag the date. We will rip apart the date manually and then recombine it.
Start by ripping apart the date into Day, Month and Year
Day
=MID(A2,4,2)
Month
=Left(A2,2)
Year
=Right(A2,4)
Now we will want to combine those values into the DATE(year,month,day) function.
=DATE(Right(A2,4),Left(A2,2),MID(A2,4,2))
Now you will want to use that in your DATEDIF formula
=DATEDIF(DATE(Right(A2,4),Left(A2,2),MID(A2,4,2)),NOW(),"y")
This assumes your dates are in the A column starting in ROW 2. Place the above formula in B2 and copy down. This is all based on your dates being text and not serial dates.

Excel: Date format is throwing up random numbers when using a function

I am using a INDEX, MATCH function in sheet Car Search to pull data from sheet Raw Data. One of the cells is Date Purchased, this will show the date in format dd/mm/yyyy (UK Format).
The problem is, when I enter a date in this format, it doesn't correctly pull over to the Car Search sheet. Instead, it shows up 42350 when I entered 12/12/2015 in the Raw Data sheet.
Both cells have been formatted to Date, but it is still showing up as 42350 and not 12/12/2015.
Is it because the function is preventing it from showing date format?
Anybody know why Excel does this? I have tried on a new sheet, but same result.
Any help much appreciated :)
Please see images below.
if you're still not getting it after you change the format of the cell, you can surround the index/match formula you've written with =text(b4, "mm/dd/yyyy") which will format the 5 digit number you've gotten as a date.

Date functions in Excel VBA only return 12/30/1899

In Excel VBA, i'm trying to read a date from a cell. The cell contains the date in the form "dd.mm.yyyy" (I'm in Germany). What I need specifically is the month. But when trying to read the month, Excel returns "12" every time. By trying Day() and Year(), I found out that the cell is recognised as blank cell and thus only returns the date of 12/30/1899, when obviously the date is entered correctly.
So this is what I'm trying to do which doesn't work (to put it as simply as possible):
ActiveSheet.Range("K2") = Month(B2)
And there you go, I get a "12" in K2, when the date is actually 02.02.2016.
You need to understand that Excel stores dates as numbers, which are formatted to appear like dates in the current locale. The earliest date Excel can show is 1/1/1900, which is the number 1 in General format.
The date 15-July-2016 is the number 42566. That is the number of days since 1/1/1900.
To establish if a cell contains a real date, try formatting it with a different number format. Once you've established that it is a number and can be formatted as a date, you can move on to the next troubleshooting step.
You're not referencing cell B2 correctly. Try
ActiveSheet.Range("K2") = Month(ActiveSheet.Range("B2"))

Increment column based on date - Excel

I am trying to create an excel formula that will increment as the year changes. The following is what i am trying to do:
http://i58.tinypic.com/nbc1fc.jpg
I have 2 columns - date and id.
What i would like to do is increment the ID column by +1 when the year changes in the date column. So, dates from the same year will get the same id. (i am not concerned by the month/day values, all i need to do is assign the same id to dates from the same year).
I have tried a variety of formulas in excel but my excel skills are not great and i have been unable to find a solution. The best i could come up with is:
IF(YEAR(A1=1928),420) but that would be quite monotonous to do for every year in the excel file.
i did try to do a bit of research and the only similar question that i could find on here was this -->
Increment number when Date changes
Any help would be much appreciated
Please try, in say B2 assuming your data starts in A1:
=IF(YEAR(A2)=YEAR(A1),B1,B1+1)
and you have chose a value for B1. Copy down to suit.

Resources