Excel - Date/time subtraction

December 2016



Issue


Ineed a macro that will subtract date-time in column A with the Present Date-time and display the value as number of days..

(Sample Calculation performed at 6/1/2012 21:00)
-------A----------------------------B------------------------

6/1/2012 21:44-----------------0
6/2/2012 12:42-----------------1
6/3/2012 08:44-----------------1
6/5/2012 20:44-----------------2
2/1/2012 22:32-----------------126
5/3/2012 11:11-----------------35


Values in column A can vary so calculation is done according to it..

Solution


Suppose that the data is A1 to B6

In C1 type this formula
=NOW()-A1 

In D1 type this formula
=DAY(C1) 

Highlight c1 and d1 and copy them down



Thanks to RWomanizerfor this tip.

Related :

This document entitled « Excel - Date/time subtraction » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.