Knowledge Base

Welcome to The Carlisle Group's Knowledge Base.

Search or Ask a Question

This is a keyword search that looks for matching articles that contain one or more words specifically by a user in articles’ tags, title and content. Admin writes brief intro content here via admin end. If you are unable to find an answer to your issue, please submit an issue here.

Back to Articles List

Date Difference - CAS mdiff and Excel DATEDIF | CAS

Added: 12/01/2015; Last Modified: 12/01/2015; Visits:1,890

If you try to tie out Excel's DATEDIF function to CAS's mdiff funtion, you won't always tie out.  This is especially true if you work with non first-of-month dates. 

DATEDIF in Excel looks at the days value to calculate months difference, whereas mdiff in CAS only looks at the Months value.

To tie out to Excel's DATEDIFF function, use the following expression in CAS, where DATE1 is the later date and DATE2 is the earlier date:

if ((dayDATE1) lt (dayDATE2))(0 max (DATE1mdiffDATE2) minus 1)(0 maxDATE1mdiffDATE2)

 

 

 

 

KEYWORDS EXCEL DATES DATEDIF MDIFF months difference