Focal Point
Function to determine the minimum or maximum date/time from a list of values

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/3531023132

June 06, 2007, 01:04 PM
Francis Mariani
Function to determine the minimum or maximum date/time from a list of values
I was hoping to use the MAX function to determine the maximum value from a list of date/time values.

I get this error: (FOC281) ALPHA ARGUMENTS IN PLACE WHERE NUMERIC ARE CALLED FOR

obviously, because MAX appears to be a Numeric function.

There is no Standard Date/Time function to do this?

Thank you.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
June 06, 2007, 01:24 PM
Leo L
What is the field type? I'm using
TIMESTAMP/HYYMDS = ...

and I was able to use the MAX.TIMESTAMP and get it to return correctly. But I am using WebFocus 7.61 and perhaps it has changed in the recent versions (seeing you're using 5.3)


Prod: WebFOCUS 7.6.4 - Self Service - Windows Server2003 - Apache Tomcat 5.5
Dev: WebFOCUS 7.6.4 - Self Service - Windows XP SP2 - Apache Tomcat 5.5
June 06, 2007, 01:54 PM
Darin Lee
We're on 7.1.6 and we use MAX on alpha fields all the time with no problem. I can't think of an example where we've used it on a date field, but I'm sure we have somewhere along the way. Do you have some code we can look at?


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
June 06, 2007, 01:55 PM
Alan B
I presume you mean MAX(date1,date2,date3). No standard function and the alternative, which I have done is horrible, really horrible. You can have it if you are desperate!


Alan.
WF 7.705/8.007
June 06, 2007, 02:10 PM
Darin Lee
You meant the MAX function instead of the MAX prefix, right? Was misdirected by Leo's comment - but is there a reason why the prefix wouldn't work instead?


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
June 06, 2007, 02:29 PM
Francis Mariani
I want to use the MAX FUNCTION to determine the maximum value from multiple columns in one ROW. The MAX function works with numeric columns only, it would be nice to have an HMAX function...

something like this:

LAST_UPD_DATE_TIME/HYYMDS = MAX(FEQ_USER.ADD_DATE_TIME, FEQ_USER.UPD_DATE_TIME, FEQ_USER_GROUP.ADD_DATE_TIME, FEQ_USER_GROUP.UPD_DATE_TIME, FEQ_USER_GROUP_XREF.ADD_DATE_TIME, FEQ_USER_GROUP_XREF.UPD_DATE_TIME);

This message has been edited. Last edited by: Francis Mariani,


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
June 06, 2007, 04:14 PM
Darin Lee
You're right - make sense that there should be something like that. To get around it, you could create a second column for each date subtracting it from current date/time. This would give you a numeric column that you could use with the MIN function. Or you could convert each date column to JULIAN which is a numeric format that you could use with MAX. (But I guess that would only work for dates, not date/time)


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
June 06, 2007, 04:48 PM
Darin Lee
Something like this:

DNOW/HYYMDm=HGETC(10,'HYYMDm');
DIFF1/D12=HDIFF(DNOW,DATE1,'DAY','D12');
DIFF2/D12=HDIFF(DNOW,DATE2,'DAY','D12');
DIFF3/D12=HDIFF(DNOW,DATE3,'DAY','D12');
MINDIFF/D12=MIN(DIFF1,DIFF2,DIFF3);
MAXDATE/YYMD=IF MINDIFF EQ DIFF1 THEN HDATE(DATE1,'YYMD') ELSE IF MINDIFF EQ DIFF2 THEN HDATE(DATE2,'YYMD') ELSE IF MINDIFF EQ DIFF3 THEN HDATE(DATE3,'YYMD') ELSE ' ';


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat