Leading the way in Microsoft Office Development
 Home|Excel|Word|PowerPoint|Consultancy|Feedback|Contact 
 Microsoft Excel > Dates & Times > Useful Formulas< Previous | Next > 

 

Please contact us if you have any useful formulas we can add to this page.

 
 

To make a contribution to this website please e-mail us. feedback3@bettersolutions.com

 

 

1) Calculate the number of days in a particular month

 
 
 AB
121/01/2005Jan = 31
218/02/2004Feb = 29
318/02/2005Feb = 28
406/04/2005Apr = 30
519/06/2005Jun = 30
626/09/2005Sep = 30
712/11/2005Nov = 30
 
 

=DAY(DATE(YEAR(A1),MONTH(A1)+1,1,-1) = 31

 
 

=DAY(DATE(YEAR(B1),MONTH(B1)+1,1,-1) = 29

 
 

=DAY(DATE(YEAR(C1),MONTH(C1)+1,1,-1) = 28

 
 

=DAY(DATE(YEAR(D1),MONTH(D1)+1,1,-1) = 30

 
 

=DAY(DATE(YEAR(E1),MONTH(E1)+1,1,-1) = 30

 
 

=DAY(DATE(YEAR(F1),MONTH(F1)+1,1,-1) = 30

 
 

=DAY(DATE(YEAR(G1),MONTH(G1)+1,1,-1) = 30

 

 

2) Calculate the number of days between 2 dates

 
 
 AB
101/01/200528/01/2005
 
 

=DATEDIF(A1,B1,"D") = 27

 
 

=DATEDIF("01/01/2003","28/01/2003","D") = 27

 
 

="01/08/03"-"28/08/03" = 27

 
 

=B1-A1 = 27

 

 

3) Calculate the number of months between 2 dates

 
 
 AB
101/06/200428/01/2005
 
 

=DATEDIF(A1,B1"M") = 7

 
 

=DATEDIF("01/01/2003","28/04/2003","M") = 7

 

 

4) Calculate the time elapsed between 2 times

 
 
 AB
19:36:00 PM3:00:00 AM
 
 

=MOD(A1-B1,1) = 21:36

 
 

=MOD(TIME(21,36,0)-TIME(3,0,0),1) = 21:36

 

 

5) Calculate the number of days that have passed in the current year

 
 
 AB
102/01/200401/06/2004
 
 

=A1-DATE(YEAR(A1),1,0) = 2

 
 

=B1-DATE(YEAR(B1),1,0) = 153

 
 

="02/01/2004"-DATE(YEAR("01/01/2004"),1,0) = 2

 
 

=DATE(2004,1,2)-DATE(2004,1,0) = 2

 

 

6) Calculate the number of days left in the current year

 
 
 AB
131-Aug-05=NOW() = 31-May-07
 
 

=DATE(YEAR(A1),12,31)-A1 = 122

 
 

=DATE(YEAR(B1),12,31)-NOW() = 134

 
 

=DATE(YEAR("19/08/2005"),12,31)-NOW() = 133

 
 

=DATE(YEAR(NOW()),12,31)-NOW() = 134

 

 

7) Calculate the corresponding number for a given month

 
 
 AB
1JanuaryNovember
 
 

=CHOOSE(MATCH(LEFT(A1,3),{"Jan";"Feb";"Mar";"Apr";"May";"Jun";"Jul";"Aug";"Sep";"Oct";"Nov";"Dec"},0),1,2,3,4,5,6,7,8,9,10,11,12) = 1

 
 

=CHOOSE(MATCH(LEFT(B1,3),{"Jan";"Feb";"Mar";"Apr";"May";"Jun";"Jul";"Aug";"Sep";"Oct";"Nov";"Dec"},0),1,2,3,4,5,6,7,8,9,10,11,12) = 11

 

 

8) Calculate a person's age in years

 
 
 AB
11-Jul-7716-Aug-84
 
 

=INT(YEARFRAC(TODAY(),A1,1)) = 27

 
 

=INT(YEARFRAC(TODAY(),B1,1)) = 21

 
 

=INT(YEARFRAC(TODAY(),"19/09/1958",1)) = 45

 

 

9) Displaying the current time

 
 
 AB
1=NOW() = 19/08/2005 : 10:52=TODAY() = 31/05/2007
 
 

=A1-B1=10:52:37

 
 

=NOW()-TODAY() = 10:52:37

 

 

10) Converting a Date String to a Date Value

 
 

If you have the date entered as a string (e.g. "20050701" in the format "yyyymmdd") this formula returns the corresponding date serial number.

 
 
 AB
12005070120041217
 
 

=DATEVALUE(RIGHT(A1,2)&"/"&MID(A1,5,2)&"/"&(LEFT(A1,4))) = 38534

 
 

=DATEVALUE(RIGHT(A1,2)&"/"&MID(A1,5,2)&"/"&(LEFT(A1,4))) = 01 July 2005

 
 

=DATEVALUE(RIGHT(B1,2)&"/"&MID(B1,5,2)&"/"&(LEFT(B1,4))) = 38338

 
 

=DATEVALUE(RIGHT(B1,2)&"/"&MID(B1,5,2)&"/"&(LEFT(B1,4))) = 13 December 2004

 

 

11) Displaying a date in a particular format

 
 
 AB
101/01/197316/08/2002
 
 

=TEXT(A1,"dd mmmm, yy") = 01 January, 73

 
 

=TEXT(B1,"dd mmmm yy") = 16-Aug 02

 
 

=TEXT(TODAY(),"dd mmmm, yy") = 19 August, 05

 
 

=TEXT("01/07/2005","dd mmmm, yy") = 01 July, 05

 

 

Calculate the number of days left in the month

 


 Copyright © 2004-2007 Better Solutions Limited. All Rights Reserved.< Previous | Top | Next >