CalculateDateDifference

Calculate the differences between two dates and stores the calculation in a user defined variable.

Syntax

bool CalculateDateDifference (string startDate, string endDate, string targetVariable, string dateProperty)

Parameters

  • startDate : The starting date
  • endDate : The ending date
  • targetVariable : The variable to hold the calculated result value
  • dateProperty : The value to calculate, 0 = days, 1 = months, 2 = quarters, 3 = years.

Smart parameters are supported.

Returns

False if the format of either date is invalid. Otherwise, True.

Level

Any level.

Details

Calculates the number of days, months, quarters or years between two dates. Only whole numbers are returned. Any fractional parts of the value are dropped. Quarters are calculated simply by dividing the number of months by 3. The order of the dates does not matter.

This action only supports Gregorian short dates as input and the date format must match the default format of the current locale.

Example
CalculateDateDifference("4/20/2012", "5/19/2012", "@P.Months", 1)

This example creates the page variable Months with a value of 0.

CalculateDateDifference("4/20/2012", "5/20/2012", "@P.Months", 1)

This example creates the page variable Months with a value of 1.

CalculateDateDifference("4/20/2012", "4/19/2013", "@P.Years", 3)

This example creates the page variableYears with a value of 0.

CalculateDateDifference("4/20/2012", "4/20/2013", "@P.Years", 3)

This example creates the page variable Years with a value of 1.

CalculateDateDifference(@P\MyDate1, @P\MyDate2, "@P.Days", 0)

This example creates the page variable Days with the number of days between the dates specified by the values in field MyDate1 and field MyDate2.

CalculateDateDifference(@P.MyDate1, @P.MyDate2, "@P.Days", 0)

This example creates the page variable Days with the number of days between the dates specified by page variables MyDate1 and MyDate2.