calculate with date format

xymcrush17

New Member
Joined
May 17, 2014
Messages
49
hi mr excel i have question
[TABLE="width: 500"]
<tbody>[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]2[/TD]
[TD]2013-12-20[/TD]
[TD]18
[/TD]
[TD]2014-01-10[/TD]
[TD]0
[/TD]
[TD]8
[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]4[/TD]
[TD]2014-01-04[/TD]
[TD]0
[/TD]
[TD]2014-02-10[/TD]
[TD]0
[/TD]
[TD]6
[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"]5[/TD]
[TD]2014-02-01[/TD]
[TD]-4
[/TD]
[TD]2014-03-01[/TD]
[TD]0
[/TD]
[TD]-25
[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]1[/TD]
[TD]2014-01-29[/TD]
[TD]28
[/TD]
[TD]2014-03-10[/TD]
[TD]1
[/TD]
[TD]9
[/TD]
[/TR]
</tbody>[/TABLE]

Red words is the result that my expected

where

D1 = C1-B1 (date)

F1 = E1-C1 (month) (and different month will subtract 1)

G1 = E1-B1 (date)

thank you in advance
warm regard
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
hi,

in D1: =DAY(C1)-B1
in F1: =DATEDIF(C1,E1,"m")
in G1: =DAY(E1)-B1

note that datedif is an undocumented function, see this for more detail: Excel DATEDIF Function worth noting that as shown here datedif returns complete months so is not quite the same outputs as your proposed answers.

Hope this helps.

Regards
 
Upvote 0
hi,

in D1: =DAY(C1)-B1
in F1: =DATEDIF(C1,E1,"m")
in G1: =DAY(E1)-B1

note that datedif is an undocumented function, see this for more detail: Excel DATEDIF Function worth noting that as shown here datedif returns complete months so is not quite the same outputs as your proposed answers.

Hope this helps.

Regards

Thank you

F1= DATEIF is return !num#
 
Upvote 0
I assume you actually entered DATEDIF rather than DATEIF, if so I you'll need to check the format of the input cells. It worked for me and I simply cut and pasted from your original post.

HTH
 
Upvote 0
hi, the datedif as setup here returns 1 because there is 1 full month between the two dates, hence the formula correctly returns a blank. If you want to compare the actual month numbers you need to use month(date)-month(date) but this fails when the dates are in different years. Not sure this is very helpful - it depends on what precisely you want to achieve.

Regards
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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