Exago Logo
Search
Generic filters
Exact matches only

Custom Function: Year to Date Check

This Custom Function must be implemented by a system administrator before it can be used in a report. Contact the System Administrator for more information.
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))

Arguments

1. dateValue – A date, dateTime, or date string that will be inspected to see if it is within this 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 this YTD
DateTime firstDay = new DateTime(DateTime.Today.Year, 1, 1);
if(myDate >= firstDay && myDate <= DateTime.Today)
{
  retVal = true;
}
return retVal;
Was this article helpful?
0 out of 5 stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.
Table of Contents