Returns true if the provided date value is within last year to date, otherwise returns false.
Note: This function is intended to be used for conditional aggregates. If one wanted to calculate the sum of one data field within the bounds of last year to date, they would use this structure:
=AggSum( If( LastYTDCheck( {dateField} ), {fieldToSum}, 0))
Arguments
1. dateValue - A date, dateTime, or date string that will be inspected to see if it is within last year to date.
Code
//create return value and grab user input bool retVal = false; DateTime myDate = DateTime.Parse(args[0].ToString()); //return true if input date is within last YTD DateTime firstDay = new DateTime(DateTime.Today.Year - 1, 1, 1); DateTime lastDay = new DateTime(DateTime.Today.Year - 1, DateTime.Today.Month, DateTime.Today.Day); if(myDate >= firstDay && myDate <= lastDay) { retVal = true; } return retVal;