Formula to calculate DATE as TEXT - excel

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.

Related

Excel formula to look up a value using Row and Column values in a table

This is a two part question. I want to lookup a price of an item based upon the effective date of the price. I've seen the vertical effective date examples but mine is somewhat different. I have the Items in the first column (A). The remaining columns contain a header with the effective date of the price. Hopefully I'm able to attach the format example. The reason I have the table formatted this way is that I don't want to duplicate the items when a new price is entered. So, I want to provide the formula an ITEM and then select the current price base upon the effective date. Right now the table has 2 effective date columns. So,The second question is how can I format the table so when I add a NEW price with a new effective date (an additional column) without having to change the look-up formula? Can the formula be formatted to be dynamic?
Thanks in advance for your input.
As per my comment:
The formula in B11:
=INDEX(1:8,MATCH(A11,A:A,0),MATCH(TRUE,INDEX(ISBLANK(1:1),),0)-1)
As you notice I have populated A1 to get this working correctly.
You can use:
=INDEX(1:1040000,MATCH("ITEM1",A:A,0),MATCH(1E+99,1:1))
If the date is always equal to or less than today I would use:
=INDEX(1:1040000,MATCH("ITEM1",A:A,0),MATCH(TODAY(),1:1))
Where the item can be replaced with a cell reference that contains the item to be looked up.
Please refers to JvdV's table, another shorter formula option
In B11, enter formula :
=LOOKUP(9.9E+307,INDEX(1:8,MATCH(A11,A:A,0),0))
Thank you everyone for your input. It was invaluable for working a solution to my problem.

Converting month number from full date cell into text month in Excel

So I have a pretty long column with name dates and hours, like this:
14/01/2017 03:30
(They are DD/MM/YYYY HH:MM)
I need to get the month number and show it as text, like January, February, and so on.
If I format the destination cell as 'MMM' all the column cells show January even if the given month is 2, 3, or let's say 12. I also tried the formula =TEXT(L2,"mmmm") (since the given info come from column F.
Any ideas?
sounds like your date and time are stored as text and not in excels serial date format. You can test this by changing the format of the cell to general and seeing if anything happens if nothing changes then its text. another way would be to use the formula =istext(A1) where A1 is a cell with a date in it.
Now ASSUMING you do have dates in text format, I would suggest converting them to excels date serial. There are numerous ways of doing this. I will show you one way.
This will strip each component of the text out and then recombine it. We will assume your date in is A1
Strip out the year
=MID(A1,7,4)
Strip out the month
=MID(A1,4,2)
Strip out the day
=LEFT(A1,2)
Now to recombine it:
=DATE(MID(A1,7,4),MID(A1,4,2),LEFT(A1,2))
That will give you the date in an integer format that excel can then turn around and display as needed.
In order not to lose the time component you should strip that part off as well and combine it with the date. Remember the date is an integer, and the time is everything after the decimal. Think of time as a fraction of a day.
To get time out use:
=RIGHT(A1,5)
and to convert it to excel time:
=TIMEVALUE(RIGHT(A1,5))
and to get the two together, simply add:
=DATE(MID(A1,7,4),MID(A1,4,2),LEFT(A1,2)+TIMEVALUE(RIGHT(A1,5))
The key part to this whole thing is you will need to format that cell to display what you want. you can either choose a preformatted style from the drop down menu, or you can apply custom formatting. Setting the custom format to MMMM should display just the full name of the month.
IF you actually need the text of the month and not just the format, then you could use the formula from your question:
=TEXT(<insert appropriate formula from above>,"mmmm")
Try using MID to get the month only, then TEXT():
=TEXT(MID(A1,SEARCH("/",A1)+1,2),"MMMM")

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.

Telling whether a date is before a particular time in 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.

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.

Resources