MVSTATDATE returns the date/time for a summary statistic for a list of variables. Variables can be of different types (IE Calculated, Daily, Hourly,etc...).
SYNTAX:
MVSTATDATE(“Stat”,Offset,Grouping, DateFormat, VarNum1, VarNum2,…VarNum99)
or
MVSTATDATE(“Stat”,Offset,Grouping, DateFormat,“Where Clause”)
Stat: The statistic in quotes (ie “MAX”) of the value to calculate. NOTE: only works for statistics that return a single value (i.e. Max, Min) not aggregate functions such as Avg, Sum as there is no specific date where the statistic occurs.
Stat |
Notes |
Max |
Maximum value |
Max_VarNum |
Returns the Variable Number of the variable that has the maximum value. |
Min |
Minimum value |
Min_VarNum |
Returns the Variable Number of the variable that has the minimum value. |
First |
First value found by date |
First_VarNum |
The variable number of the variable that is the first value found. |
Last |
Last value found by date |
Last_VarNum |
The variable number of the variable that is the last value found. |
GroupOffset/StartDate: Used with the Grouping parameter to set the dates to calculate the stat for. Sets the number of Groups (set by the Grouping Parameter) to be added to set the dates. See examples below. If this field is a date string (i.e. "07/16/2004") or refers to a cell with a date in it, it is assumed to be the start date to calculate the stat for.
Grouping/EndDate: Used to set which dates to calculate the stat for. If the Grouping is a date literal string (i.e. "07/16/2004") or refers to a cell with a date in it, it is assumed to be the end date to calculate the stat for. Common Groupings are:
"D" Days
“M” Monthly
"R" Report Dates
Click here for available Grouping options
DateFormat: Date Format (i.e. "mm/dd/yyyy"...) to return.
VarNum1..VarNum99: A comma separated list of variables that sets which variables to calculate from.
Where clause Instead of providing a list of variables, you can use an SQL Where clause against the VarDesc table to get the list of variables. I.E. “Units = 'mg/L'” wound return all variables with Units set to mg/L. See Examples.
SEE ALSO:
MVSTAT, MVSTATZ
EXAMPLES:
MVSTATDATE("MIN",1,"M","mm/dd/yyyy hh:nn",4011,4041) Returns the Date/Time (i.e. 04/22/2008 07:00) of the minimum value for the start month of the report for variables 4011,4041.
MVSTATDATE("MAX",1,"M","mm/dd/yyyy","UNITS = 'mg/L'") Returns the Date (i.e. 04/22/2008) of the maximum value for the start month of the report for variables that have mg/L as their units.
Download Example Template: Help_MVStat.ss3 (Click here for download instructions)