Aggregate Not Getting The Result I need

I have a database with a date field named WeatherDate. I have a variable fgFieldName with the name of this field as its value. I want to find the maximum and minimum values, i.e., the earliest and latest dates, in the WeatherDate field. These formulas are not working correctly:

MinDate=aggregate({formulavalue(fgFieldName)},“min”)
MaxDate=aggregate({formulavalue(fgFieldName)},“max”)

Both formulas are returning the WeatherDate value in the first row. Is there a way to get aggregate to work like this? (I know I can use an execute statement to work, but this would be nicer.)

I would try:

MinDate=aggregate({formulavalue(""+fgFieldName)},“min”)
MaxDate=aggregate({formulavalue(""+fgFieldName)},“max”)

So far, I have not gotten this to work. The aggregate formula is returning the value of the fgFieldName field in the active record, but does not find the min or max.

The formulavalue( function calculates the result of a formula based on data in the current record of any open database.

You simply need to take that function out of the formula.

MinDate=aggregate(fgFieldName},“min”)
MaxDate=aggregate(fgFieldName,“max”)

This procedure worked perfectly, even though the minimum wasn’t in the current record

letfileglobal fgFieldName=info("fieldname")
let theMinimum = aggregate(fgFieldName, "min")
message theMinimum
1 Like