Sum between 2 dates

Laguna11

New Member
Joined
Sep 25, 2010
Messages
26
Quick question: is it possible to find the difference between 2 dates that contain text? Eg. 15/6/2011pm - 16/6/2011 am The answer being 1.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
A more helpful answer, try:
Code:
=TEXT(LEFT(A2,9),"dd/mm/yyyy")-TEXT(LEFT(A1,9),"dd/mm/yyyy")
 
Upvote 0
=abs(substitute(upper(substitute(upper(a1),"PM","")),"AM","")-substitute(upper(substitute(upper(b1),"PM","")),"AM",""))
 
Last edited:
Upvote 0
Is it real text, or is the text just there from the cell format?

Formatted dates are still numbers so can be calculated as such, i.e. =B1-A1
 
Upvote 0
It would be entered as dd/mm/yy occasionally with the suffix of pm or am if a half day is taken of leave.

Thx for the replies I'll try them out now!
 
Upvote 0
Without the suffix the date is a number, with the suffix the date is text, You will need a formula to allow for mixed formats of the dates.

Is there an exact entry format used, or is it user dependant?

1/1/11PM
01/01/2011 PM

Both the same but in different entry formats, whare a formula for one will fail with the other.
 
Upvote 0
Its been answered read the post's

I did!

Look at the first line of #6, "It would be entered as dd/mm/yy"

Then look at the dates in original question, format "dd/m/yyyy", one date has a space between year and suffix, the other doesn't.

My comment / question was based on JD's suggestion, I do stand guilty on the count of not reading your formula properly and seeing that it does as needed, if I had done that I would have commented on 2 functions that you don't need :stickouttounge:
 
Upvote 0
Personally easiest way: -note the "D" means days in the forumla, replace with "M" months and "Y" years


<b>Excel 2003</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><colgroup><col width="25px" style="background-color: #E0E0F0" /><col /><col /><col /></colgroup><thead><tr style=" background-color: #E0E0F0;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">2</td><td style="text-align: right;;">15/06/2011</td><td style="text-align: right;;">16/06/2011</td><td style="text-align: right;;">1</td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #A6AAB6;border-top:none;text-align: center;background-color: #E0E0F0;color: #161120">Sheet1</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #A6AAB6"><thead><tr style=" background-color: #E0E0F0;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">C2</th><td style="text-align:left">=DATEDIF(<font color="Blue">A2,B2,"d"</font>)</td></tr></tbody></table></td></tr></table><br />
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,634
Members
452,934
Latest member
Jdsonne31

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