How to auto populate the next week in excel - excel

I am making an on-call schedule in excel and I can't for the life of me find an easy way to populate the dates. For example, someone is on call from Monday to Sunday, January 2nd - January 8th. Then the next person is on call from January 9th - January 15th. I am trying to figure out a way or formula to just "Drag" down the column and it input the next 7 day range. I have tried input the start date and end date in a separate cell, then using concatenate but it returns the date number in excel (forgot what its called). I also tried =(A1&" - "&B1) but that returns the same 5 digit number.
Any help or pointers are greatly appreciated!

Previous date + 7
If you have genuine dates, say in cells A1 "start date" and B1 "end date":
Jan 2 Jan 8
Then the next line will be
=A1+7 =B1+7
Verify Dates
To see, if the "Dates" you entered are realy dates excel can work with like that, apply "General formatting" to the A1 and B1 cells. If the resulting value is an Interer or a Decimal number, you are golden. If the resulting value did not change, you have a text and you need to apply different approach.

Perhaps you are looking for this:
=TEXT(A1,"d-mmm")&" - "&TEXT(B1,"d-mmm")
The formatting specification can be copied from the formatted cell properties.

Related

Excel - count days in each month between two dates (both dates available)

I have found the solution thought it would be good to share:
so the formula should be :
=((MAX(CT$6-$N8,0)-MAX(EOMONTH(CT$6,-1)-$N8,0))-(MAX(CT$6-$O8,0)-MAX(EOMONTH(CT$6,-1)-$O8,0))+(EOMONTH(CT$6,0)=EOMONTH($N8,0)))*1
:)
I am trying to write an excel formula which can be dragged across a row of cells to give the number of days in each month between two specified dates. E.g:
I tried using a if with sum product formula from the same website but for some reason it is not recognising the days of last month. was wondering if someone could help explain what this formula does and how to correct it.
=IFERROR(IF(AND(CS$6>=$M9,CS$6<=$N9),SUMPRODUCT(--(MONTH(ROW(INDIRECT($M9&":"&IF($N9="",TODAY(),$N9))))=MONTH(CS$6))),),"")
SECOND REVISION (R2)
Updated workbook link to capture fixed column headings
Eqn / formula also includes static view
Depending upon years spanned, R2 represents a less favourable outcome re space (will require more columns). In this case, number of additional columns required to match stacked view ~100 (!!).
FIRST REVISION (R1) etc. based upon #Charlotte.Sarah.Smith feedback
Days in each month were 1 day less than they should have been - this has been corrected (in both screenshot, linked sheet, and relevant eqns)
Also showcase a couple of sample illustrations/visual representations which may/not be of interest (included within linked sheet too)
Suppose we wanted to expand upon #Will's solution by stacking the dates by year, so that column headings can vary according to different start dates (as opposed to the very first start date that happens to appear)...
For instance, if the next row included the date range 'start = 10/02/16' through 'end = 15/03/19' - you'll appreciate that the number of columns spanning Jan-Dec ('16), Jan-Dec ('17),... up to (and incl.) the range in the first row (Jan '21 - Mar '23) becomes unwieldy.
By using a data table (see here) you can produce a 'stacked' view of the number of days per month regardless of the year (!) - see screenshot below and link to this [updated/corrected] worksheet.
R2 screenshot:
REVISION
See validation/reconciliation column at end
*Visual representations - could be useful for assessing trends etc.
Fun in 3D too!
1] Red font: first row that defines the construct of the data table: enter date range in the format '10/02/2021-15/08/2023'
Cell E3 eqn (drag to right):
=IFERROR(IF($A3>EDATE(E$2,1),0,MAX(,IFERROR(IF(MIN($B3,MIN(EDATE(E$2,1),$B3))=E$2-1,0,MIN($B3,MIN(EDATE(E$2,1),$B3))),"")-MAX($A3,E$2))),0)
(Similar to what we've seen previously)
2] Table below red font: enter any start date (as a regular date, e.g. dd/mm/yyyy) < end date (likewise, regular date) in columns A, B as desired/req.
Data Table
3] Data Table (column data): enter the following in cell c4 (drag down as req.)
=TEXT(A4,"dd/mm/yyyy")&"-"&TEXT(B4,"dd/mm/yyyy")
4] Data Table (highlight cells c3:d42, insert data table, select blank/empty cell for 'row input' and c2 for 'column input')
The data table should 'come to life' (calculate sheet, shift + F9) otherwise.
FilterXML
5] Split result by delimiter '|' using FilterXML as follows (cell E4, only drag down, not to right):
=IFERROR(TRANSPOSE(FILTERXML("<AllText><Num>"&SUBSTITUTE(LEFT(MID(D4,2,LEN(D4)-1),LEN(MID(D4,2,LEN(D4)-1))-1),"|","</Num><Num>")&"</Num></AllText>","//Num")),"")
VALIDATION
Note the check column: date difference = sum of days in table (default cell colour is otherwise RED):
REVISION 2
Here is the formula for a static version of above (i.e. no stacking by year, instead, each date in column headers are distinct re calcs) - it was already available in row with red font(!!)
=IFERROR(IF($A3>EDATE(C$2,1),0,MAX(,IFERROR(IF(MIN($B3,MIN(EDATE(C$2,1),$B3))=C$2-1,0,MIN($B3,MIN(EDATE(C$2,1),$B3))),"")-MAX($A3,C$2))),0)
Viola!
One potential solution would be to compare dates using the MIN and MAX functions like this:
=IF(MIN($B2+1,D$1)-MAX($A2,C$1)<0,"",MIN($B2+1,D$1)-MAX($A2,C$1))
screenshot
This solution uses month starting dates (e.g., Feb 1, 2021), but it could be adapted to work with month end dates instead (e.g., Feb 28, 2021).
The idea is that you take the later of the finish date or month end date minus the lesser of the start date or the month start date. For the first month and last months, this returns the number of days within that range inclusive of the first and last day. For all the months between the first and last months, it returns the number of days in the month.
The +1 on the minimum of the end dates seems a little counterintuitive, but it's necessary to include the first and last day in the count. Without it, you'd get 14 days in March 2022 instead of 15.
The "if less than zero" function makes it return a blank (or zero if you'd prefer) for any month outside the dat range.
This solution does not summarize by month (e.g., 19 days for Feb 2021 plus 28 days for 2022 to get 47 total days in February), but that's consistent with the sample you provided. The comments also indicate that you want to consider the years as well.

Excel: Check cell for date

Short story short:
I want to check the cell C21 if it contains a date. I can't use VB cause it's deactivated by GPO.
Used this from this page
D21 contains this:
=WENN(ISTZAHL(DATWERT(C21));"date";"no date")
in english
=IF(ISNUMBER(DATEVALUE(C21))...
C21 this:
=HEUTE() # in english: =TODAY() Maybe other dates later, but allways in the correct format
but it allways returns "no date"
Use this: =IF(LEFT(CELL("format",C21))="D",..,..). Learn more about CELL formula here.
In your example =TODAY() already a real date and not a date stored as text, so doesn't make too much sense to use DATEVALUE there.
Update
Here are some example dates and how CELL recognize them:
format value output
dd/mmmm/yyyy 12/June/2015 D1
dd/mm/yyyy 12/06/2015 D1
yyyy 2015 G
general 2015 G
dd/mm 12/06 D2
mmmm June G
dd mmmm yyyy 12 June 2015 G
Note: CELL is not volatile, so if the format of source cell is changed it won't be refreshed automatically, you need to either recalculate your sheet / book, either open the formula and press enter (also automatice recalculation initiated by any other volatile formula will cause it to refresh).
Use this formula, the expression will return TRUE if cell A1 contains an invalid date.
=ISERROR(DATE(DAY(A1),MONTH(A1),YEAR(A1)))
This formula works by evaluating each component part of the date: DAY, MONTH and YEAR and then aggregating them using the DATE function.
ISERROR will the catch any errors by returning TRUE (invalid) otherwise FALSE (valid).
Obviously the date value in cell (A1) must contain values >= 01/01/1900.
Useful for "Conditional Formatting".
Excel stores dates as numbers. 1 is 1-Jan-1900.
When it comes to numbers in a cell, Excel cannot tell if a number is meant to be a number or a date.
Today is 11/06/2015 as a date and 42166 as a number. For the consumer of a spreadsheet, the cell can be formatted to display the number as any number format or as a date. Excel formulas cannot tell whether the number in that cell is "meant" to be a date.
So, there is no Excel formula that you can use in a spreadsheet that will tell you if cell A1 is about 42166 widgets or if contains the date of June-11-2015.
Some of provided answers, checks cell format, which will not considers cell value, as you can format differently each cell no matter of its content, for checking if a cell value is date you can use this:
if(ISERROR(VALUE(c21)),"No Date", ----do staff for Date ----)
or shorter version which just will inform you "no date" status. If a date entry is find, it will return its numerical value instead:
IFERROR(VALUE(c21),"No Date")
hope this helps,
Cheers,
M
use the following formula ...
=IF(NOT(ISERROR(DATEVALUE(TEXT(C21,"mm/dd/yyyy")))),"valid date","invalid date")
I think it will solve your problem.
If the value is a string this method would work.
TEXT(DATE(VALUE(RIGHT(AI8,4)),VALUE(MID(TRIM(AI8),4,2)),VALUE(LEFT(AI8,2))),"dd.mm.yyyy") = AI8
Just wanted to add to the discussion that although you can check with a date(year;month;day) it will give you false positives, since the way it works is that it seems to just roll over values that exceed the logical limit, i.e. if you have the date 99-12-35 it will assume that you meant to write Jan 4th 2000, since that is the 35 - the 31 days of December. In other words, you will find some errors, but not all. Same goes for months exceeding 12.
try this formula (depends on date format):
=IF(DATE(TEXT(C21;"yyyy");TEXT(C21;"mm");TEXT(C21;"dd"));"contains date";"doesn't")
I tried every solution posted but none of them work if there are empty cells in the date cells, so I added a check to GBGOLC's answer and now it works with empty cells:
=IF(NOT(OR(ISBLANK(C21),ISERR(DATE(DAY(C21),MONTH(C21),YEAR(C21))))),"Yes it is a date","Not a date")

Excel #Value! error - but correct formula

I have an Excel 2010 workbook with this formula:
=EOMONTH("01"&TEXT(B7,"MMM")&IF(MONTH(CMVAR)<4,TEXT(YEAR(CMVAR)-1,"YYYY"),TEXT(YEAR(CMVAR),"YYYY")),0)
It resolves when you are in the cell and press Enter, however when the workbook first opens or is refreshed, the result is #VALUE!. Here are the components:
B7 =IF(OR(MONTH(CMVAR)>6,MONTH(CMVAR)<4),"Apr",IF(MONTH(CMVAR)=4,TEXT(EDATE(CMVAR,-3),"MMM"),IF(MONTH(CMVAR)=5,TEXT(EDATE(CMVAR,-3),"MMM"),TEXT(EDATE(CMVAR,-3),"MMM"))))
which equates to Apr.
CMVAR 31/03/2015
The formula is being used because in April, May, June (first three fiscal periods) we require comparison data to show in the 12-period grid from the previous financial year. From July onwards we will have comparable data from the current year and so the grid can start from April. Once the month has been determined I'm trying to work out what the date of the end of that period is, taking into account that Jan, Feb and Mar are actually periods 10, 11 and 12 of the fiscal year and so the year element of the formula will be the prior year if CMVAR shows the date to be in any of those months.
Is there a better way that avoids the error or a way to fix it?
It is not completely clear what result do you expect for different values of CMVAR, but looking at your formula, I suppose you want it to be:
You can calculate Result with the following formula:
=EOMONTH(CMVAR,-MAX(MOD(MONTH(CMVAR)-4,12),3))
If the picture above does not show your expected output, can you please prepare similar table?
EDIT:
To explain how the problem is solved, I have created additional columns with intermediate calculations:
column C is the month difference between CMVAR and expected result - the goal is to find a formula returning this number
column D calculates month of CMVAR
column E - function MOD returns the remainder after number is divided by divisor (12).
column E matches all values of C, except 0,1,2, so in column F function MAX replaces those values with 3
Your EOMONTH formula is going wrong because the TEXT part should be in the form TEXT(date,"YYYY"). YEAR(CMVAR) gives a number rather than a date.
You could use instead
=EOMONTH("01"&TEXT(B7,"MMM")&IF(MONTH(CMVAR)<4,TEXT(EDATE(CMVAR,-12),"YYYY"),TEXT(CMVAR"YYYY")),0)
or this may be easier than using the TEXT functions
=EOMONTH("01"&B7&IF(MONTH(CMVAR)<4,YEAR(CMVAR)-1,YEAR(CMVAR)),0)
Your B7 formula is OK but could be simplified to
=IF(OR(MONTH(CMVAR)>6,MONTH(CMVAR)<4),"Apr",TEXT(EDATE(CMVAR,-3),"MMM"))

Check if any date within a range is within 1 month of todays date

I've got a column full of dates. How can I check that column to find which date is within a month of todays date, and then return it?
If there is no date within a month, just return blank
Lets say my dates are:
01-Jan-12
01-Apr-12
01-Jul-12
01-Oct-12
01-Jan-13
The code im using is below. A:A is the range of the dates above
=MIN(IF(A:A>TODAY(),A:A))
The issue im having is that if I use the above, it returns 01/01/12 and not 01/01/13. Also, if I change the dates so the next date is December 1st 2012, it still returns 01/01/12
So you really just want the earliest date if that's within a month? If so perhaps try
=IF(MIN(A:A)-TODAY()<=30,MIN(A:A),"")
Assumes dates in column A
If you have past and future dates try this formula
=IFERROR(SMALL(IF(A2:A100>=TODAY(),IF(A2:A100<=TODAY()+30,A2:A100)),1),"")
confirmed with CTRL+SHIFT+ENTER
or for exactly 1 month (rather than 30 days) try using EDATE, i.e.
=IFERROR(SMALL(IF(A2:A100>=TODAY(),IF(A2:A100<=EDATE(TODAY(),1),A2:A100)),1),"")

IF formula to compare a date with current date and return result

I'm looking for a formula which allows me to look at a cell and check if it greater than or equal to today's date and to return a worded result such as "overdue". If it is blank to return another word, or nothing.
I have tried copying the result from the source cell (O10) into another cell (Y10) and used an if statement but this seems overly laborious - there must be a way to read the information from the source cell? See below. It also returns overdue when the cell is blank :(
=IF(O10>Y10,"OVERDUE","NOT DUE")
You can enter the following formula in the cell where you want to see the Overdue or Not due result:
=IF(ISBLANK(O10),"",IF(O10<TODAY(),"Overdue","Not due"))
This formula first tests if the source cell is blank. If it is, then the result cell will be filled with the empty string. If the source is not blank, then the formula tests if the date in the source cell is before the current day. If it is, then the value is set to Overdue, otherwise it is set to Not due.
I think this will cover any possible scenario for what is in O10:
=IF(ISBLANK(O10),"",IF(O10<TODAY(),IF(TODAY()-O10<>1,CONCATENATE("Due in ",TEXT(TODAY()-O10,"d")," days"),CONCATENATE("Due in ",TEXT(TODAY()-O10,"d")," day")),IF(O10=TODAY(),"Due Today","Overdue")))
For Dates that are before Today, it will tell you how many days the item is due in. If O10 = Today then it will say "Due Today". Anything past Today and it will read overdue. Lastly, if it is blank, the cell will also appear blank. Let me know what you think!
The formula provided by Blake doesn't seem to work for me. For past dates it returns due in xx days and for future dates, it returns overdue. Also, it will only return 15 days overdue, when it could actually be 30, 60 90+.
I created this, which seems to work and provides 'Due in xx days', 'Overdue xx days' and 'Due Today'.
=IF(ISBLANK(O10),"",IF(DAYS(TODAY(),O10)<0,CONCATENATE("Due in ",-DAYS(TODAY(),O10)," Days"),IF(DAYS(TODAY(),O10)>0,CONCATENATE("Overdue ",DAYS(TODAY(),O10)," Days"),"Due Today")))

Resources