Date to Months Function

From Relyimah

Jump to: navigation, search

This Formula will allow two dates to be compared when it is not possible to use inbuilt date functions. For example, this can be used in XPath 1.0 processing to check whether one date is greater than another date.

Contents

Formula

(Year * 12) + Month + (Day / 100)


Examples

Convert date 06/12/2007 to months:

(Year * 12) + Month + (Day / 100)
(2007 * 12) + 12 + (06 / 100)
(24084) + 12 + (0.06)
24096.06

Convert date 14/01/2008 to months:

(Year * 12) + Month + (Day / 100)
(2008 * 12) + 01 + (14 / 100)
(24096) + 12 + (0.14)
24108.14

Compare dates 06/12/2007 and 14/01/2008:

Using the above calculations, we can see that 06/12/2007 is less than 14/01/2008:

24096.06 < 24108.14
Personal tools