Date Formula

fairchance

Board Regular
Joined
Jan 4, 2015
Messages
110
Dear Sir,

I am seeking data formula/function that could calculate the number of days from the expected date to actual date.
I can come up with formula to calculate the number of dates between real dates and expected dates. Here is the example parameters:

Range Definition:(days of month)
Beg 1-10
mid 11-20
End 21-30

<tbody>
</tbody>
Expacted date for submission Actual Date Formula
21-Dec-1421-Dec-140
21-Dec-1418-Dec-14-3
21-Dec-1427-Dec-146
Beg Dec 149-Dec-14 #VALUE!
End Dec 1418-Dec-14 #VALUE!
Mid Dec 1427-Dec-14 #VALUE!

<tbody>
</tbody>
How can i calculate date difference in case of date relate to particular range? Any one can help please.

Regards

Shehbaz

<tbody>
</tbody>
 
yes please guide with input cell range, criteria cell range and output cell range so that i may place the data in right places
Moreover please review my posts in excel guru you will really enjoyed it

Date Formula - Page 2
username fairchance
password register
 
Upvote 0

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
OK but 1st try this formula, (it's a bit long), if the date in B is earlier than A it will use the lower number to calculate, if B is greater than A it will use the higher number.
e.g. A = mid jan 14, B = 24-12-13 then it will use 11 for mid,

=IF(B2="","Not Applicable",IF(ISNUMBER(A2),B2-A2,IF(AND(LEFT(A2,3)="beg",DAY(B2)<=10),0,IF(AND(LEFT(A2,3)="mid",DAY(B2)>10,DAY(B2)<=20),0,IF(AND(LEFT(A2,3)="end",DAY(B2)>=20),0,IF(AND(LEFT(A2,3)="beg",B2<DATEVALUE((1&RIGHT(A2,7)))),B2-(1&RIGHT(A2,7)),IF(AND(LEFT(A2,3)="beg",B2>DATEVALUE((10&RIGHT(A2,7)))),B2-(10&RIGHT(A2,7)),IF(AND(LEFT(A2,3)="mid",B2<DATEVALUE((11&RIGHT(A2,7)))),B2-(11&RIGHT(A2,7)),IF(AND(LEFT(A2,3)="mid",B2>DATEVALUE((20&RIGHT(A2,7)))),B2-(20&RIGHT(A2,7)),IF(AND(LEFT(A2,3)="end",B2<DATEVALUE((21&RIGHT(A2,7)))),B2-(21&RIGHT(A2,7)),IF(AND(LEFT(A2,3)="end",B2>DATEVALUE((31&RIGHT(A2,7)))),B2-(31&RIGHT(A2,7)),)))))))))))
 
Upvote 0
Above formula is wrong (forgot the site doesn't like " < ") copy it from the file in dropbox.
 
Last edited:
Upvote 0
first one question, then another different, poor definitions of what is wanted - need to build it one stage at a time

eg if a cell has "mid feb" in it how can I convert it to 14-feb-2015 (which is a normal date value)

or it is midfeb - which is harder to do

then ask questions re the next stage

and do not suddenly switch to a brand new topic
 
Upvote 0
Hi fairchance,

In your post #20 you said:
Date Range for expected date

Beg 1-10
Mid 11-20
End 21-31

If B4 > Expected date range then B4-A4=B4-last range value
If B4 within Expected date then B4-A4=0

There are three conditions are in formula you know if,than,else

Based on this I would offer the following:

=IF(ISNUMBER(--LEFT(A4,1)),B4-A4,IF(LEFT(A4,1)="B",MAX(0,B4-DATEVALUE("10 "&RIGHT(A4,LEN(A4)-FIND(" ",A4)))),IF(LEFT(A4,1)="E",MIN(0,B4-DATEVALUE("21 "&RIGHT(A4,LEN(A4)-FIND(" ",A4)))),IF(DAY(B4)<11,B4-DATEVALUE("11 "&RIGHT(A4,LEN(A4)-FIND(" ",A4))),IF(DAY(B4)>20,B4-DATEVALUE("20 "&RIGHT(A4,LEN(A4)-FIND(" ",A4))),0)))))

This produces the following results:

21-Dec-14 21-Dec-14 0
21-Dec-14 18-Dec-14 -3
21-Dec-14 27-Dec-14 6
Beg Dec 14 9-Dec-14 0
End Dec 14 18-Dec-14 -3
Mid Dec 14 10-Dec-14 -1
Mid Dec 14 23-Dec-14 3

Note that the formatting of the dates as shown above is important for this to work.

Hope this helps a bit!! If you want to understand how it works you'll need to use the 'Evaluate Formula' option on the Formula's ribbon.

Regards
 
Upvote 0
Dear Sir Gaz
Hi


I have another turn in my date formula story :)

The scenario is:

If real date is within expected date range then answer is 0
If real date is less than expected date range initial value then answer is real date - initial range value (in all three cases i.e. beg,mid,end)
If real date is greater than expected date range end value then criteria is real date-ending range value ( in all cases i.e. beg,mid,end)

Kindly amend the formula accordingly.

Regards
 
Upvote 0
That is how my new formula works! Did you look at the file in dropbox?

As posted earlier "if the date in B is earlier than A it will use the lower number to calculate, if B is greater than A it will use the higher number.
e.g. A = mid jan 14, B = 24-12-13 then it will use 11 for mid"

Gaz
 
Upvote 0
Sir Gaz!!!

How quick you are? The new formula is working correctly.

Thank you. Can i have your email address?

Kind Regards

Shehbaz H.
 
Upvote 0

Forum statistics

Threads
1,216,095
Messages
6,128,800
Members
449,468
Latest member
AGreen17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top