Custom Function: Year to Date Check

Returns true if the provided date value is within this 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 this year to date, they would use this structure:

=AggSum( If( YTDCheck( {dateField} ), {fieldToSum}, 0))


1. dateValue - A date, dateTime, or date string that will be inspected to see if it is within this year to date.


//create return value
bool retVal = false;

//get input date
DateTime myDate = DateTime.Parse(args[0].ToString());

//create first day of this year
DateTime firstDay = new DateTime(DateTime.Today.Year, 1, 1);

//check if input date is within bounds of this YTD
if(myDate >= firstDay && myDate <= DateTime.Today)
	retVal = true;

return retVal;

Hidden Article Information

Article Author
Exago Services
created 2018-08-22 14:03:01 UTC
updated 2019-03-27 21:05:49 UTC

no labels yet!
Have more questions? Submit a request