Tony A - I inspected the date-time fields (which they are epoch dates that are stored as integer fields in the database) within the data set at hand and I don't see any nulls or anything odd.
Well I decided to take the route of reading my epoch date values into amper variables and Define them in the following HOLD file (HOLDRPT). I get this error on my last TABLE request that does the report: (FOC1065) PROGRAM ERROR
Here is the log now:
0 NUMBER OF RECORDS IN TABLE= 1 LINES= 1
SET ASNAMES = ON
-DEFAULT &ST_DT = '02/01/2017';
-DEFAULT &END_DT = '02/04/2017';
-DEFAULT &METER = '135628301';
-DEFAULT &MIN_KW_THRSH = 1.5;
-*-DEFAULT &MAX_KW_THRSH = 6;
-DEFAULT &KW_CHANNEL = 1;
-DEFAULT &KV_CHANNEL = 1;
-*-DEFAULT &OPP = 3;
-*-DEFAULT &ADJ = 5;
DEFINE FILE MDM_READINGS
-*Convert dates from original Epoch
d_st_date_cvtepoch/HMDYYS=DF.convertepochvalues.EpochToDateTime1 ( MDM_READINGS.MDM_READINGS.START_DATE_MILLIS );
d_end_date_cvtepoch/HMDYYS=DF.convertepochvalues.EpochToDateTime1 ( MDM_READINGS.MDM_READINGS.END_DATE_MILLIS );
-*
d_st_date_cvte_hmdyy/HMDYY=DF.convertepochvalues.EpochToDateTime1 ( MDM_READINGS.MDM_READINGS.START_DATE_MILLIS );
d_end_date_cvte_hmdyy/HMDYY=DF.convertepochvalues.EpochToDateTime1 ( MDM_READINGS.MDM_READINGS.END_DATE_MILLIS );
-*
d_st_date_cvte_hyymd/HYYMD=DF.convertepochvalues.EpochToDateTime1 ( MDM_READINGS.MDM_READINGS.START_DATE_MILLIS );
d_end_date_cvte_hyymd/HYYMD=DF.convertepochvalues.EpochToDateTime1 ( MDM_READINGS.MDM_READINGS.END_DATE_MILLIS );
-*
d_st_date_cvte_hi/HI=DF.convertepochvalues.EpochToDateTime1 ( MDM_READINGS.MDM_READINGS.START_DATE_MILLIS );
d_end_date_cvte_hi/HI=DF.convertepochvalues.EpochToDateTime1 ( MDM_READINGS.MDM_READINGS.END_DATE_MILLIS );
-*
d_st_date_cvte_hd/HD=DF.convertepochvalues.EpochToDateTime1 ( MDM_READINGS.MDM_READINGS.START_DATE_MILLIS );
d_end_date_cvte_hd/HD=DF.convertepochvalues.EpochToDateTime1 ( MDM_READINGS.MDM_READINGS.END_DATE_MILLIS );
-*
d_st_cvtdate/I8YYMD = HDATE(d_st_date_cvte_hyymd,'YYMD');
d_end_cvtdate/I8YYMD = HDATE(d_end_date_cvte_hyymd,'YYMD');
-*
d_st_date_day/A4 = DOWK(d_st_cvtdate, d_st_date_day);
d_end_date_day/A4 = DOWK(d_end_cvtdate, d_end_date_day);
-*
INTVL_MINS/I20 = (END_DATE_MILLIS - START_DATE_MILLIS) / 60000;
-*Minimum KW Demand Calculation - 1st Part
MIN_THRSH/D12.2 = '1.5';
MIN_KW_DEM/D12.2 = IF INTVL_MINS EQ 5 THEN (VALUE * 12) ELSE
IF INTVL_MINS EQ 15 THEN (VALUE * 4) ELSE
IF INTVL_MINS EQ 30 THEN (VALUE * 2) ELSE
IF INTVL_MINS EQ 60 THEN (VALUE * 1) ELSE 0;
-*
-*MIN_KW_DEM_TEST/D12.2 = IF MIN_KW_DEM GT MIN_THRSH THEN MIN_KW_DEM ELSE 0;
-*
-*Maximum KW Demand (KWpeak) Calculation - 1st Part
MAX_KW_DEM/D12.2 = IF INTVL_MINS EQ 5 THEN (VALUE * 12) ELSE
IF INTVL_MINS EQ 15 THEN (VALUE * 4) ELSE
IF INTVL_MINS EQ 30 THEN (VALUE * 2) ELSE
IF INTVL_MINS EQ 60 THEN (VALUE * 1) ELSE 0;
END
-*Minimum KW Demand Calculation - 2nd Part
TABLE FILE MDM_READINGS
PRINT MIN_KW_DEM
BY LOWEST 1 MIN_KW_DEM NOPRINT
WHERE AMI_METER_ID EQ '135628301';
WHERE d_st_date_cvte_hmdyy GE '02/01/2017';
WHERE d_end_date_cvte_hmdyy LE '02/04/2017';
WHERE CHANNEL EQ '1';
WHERE UNIT_OF_MEASURE CONTAINS 'KWH';
WHERE MIN_KW_DEM GT 1.5;
ON TABLE HOLD AS HOLDMIN
END
-RUN
1
0 NUMBER OF RECORDS IN TABLE= 67 LINES= 2
-*Read min demand into amper variable
-SET &MIN_KW_DEM = '';
-BEGIN
(FOC2906) WARNING: &MIN_KW_DEM WILL BE OVERWRITTEN BY -READFILE HOLDMIN
-READFILE HOLDMIN
-*-TYPE &MIN_KW_DEM
-DONE
-*Maximum KW Demand Calculation - 2nd Part
TABLE FILE MDM_READINGS
PRINT MAX_KW_DEM
BY HIGHEST 1 MAX_KW_DEM NOPRINT
WHERE AMI_METER_ID EQ '135628301';
WHERE d_st_date_cvte_hmdyy GE '02/01/2017';
WHERE d_end_date_cvte_hmdyy LE '02/04/2017';
WHERE CHANNEL EQ '1';
WHERE UNIT_OF_MEASURE CONTAINS 'KWH';
ON TABLE HOLD AS HOLDMAX
END
-RUN
1
0 NUMBER OF RECORDS IN TABLE= 267 LINES= 1
-*Read max demand into amper variable
-SET &MAX_KW_DEM = '';
-BEGIN
(FOC2906) WARNING: &MAX_KW_DEM WILL BE OVERWRITTEN BY -READFILE HOLDMAX
-READFILE HOLDMAX
-TYPE 10.86
10.86
-DONE
DEFINE FILE MDM_READINGS ADD
-*KWH_VAL_2/D12.2 = '&KWH_VAL';
-*KVH_VAL_2/D12.2 = '&KVH_VAL';
-*KWH and KVH Totals
KWH_VAL/D12.2 = IF UNIT_OF_MEASURE CONTAINS 'KWH' AND CHANNEL EQ '1' THEN VALUE ELSE 0;
KVH_VAL/D12.2 = IF UNIT_OF_MEASURE CONTAINS 'KV' AND CHANNEL EQ '1' THEN VALUE ELSE 0;
-*Load Factor Calculation - Will get from other pieces of the DEFINE
-*D_LF/P20.2 = MAX_KW_DEM_2 * INTVL_HRS;
-*LD_FACT/P20.2 = KWH_VAL_2 / (MAX_KW_DEM_2 * INTVL_HRS);
-*
-*Avg Power Factor Calculation
-*POW_FACT/P20.2 = 1/SQRT(1+(KWH_VAL_2/KVH_VAL_2)*2); -*1st Formula
-*POW_FACT2/P20.2 = KVH_VAL_2/(SQRT(KWH_VALZ_2*2+KVH_VAL_2*2)); -*2nd Formula
-*
-*Lagging or Leading Calculation for Power Factor
-*LAG_LEAD_PF/P20.2 = KWH_VAL_2/(SQRT(KWH_VAL_2*2+KVH_VAL_2*2));
-*LAG_LEAD_TEST/P20.2 = IF LAG_LEAD GE 0 THEN (POW_FACT * -1) ELSE POW_FACT;
-*
-*Total Usage
TOT_USG/D20.2 = IF UNIT_OF_MEASURE CONTAINS 'KWH' AND CHANNEL EQ '1' THEN VALUE ELSE 0;
-*
-*Weekday Usage
WKDY_USG/D20.2 = IF (UNIT_OF_MEASURE CONTAINS 'KWH' AND CHANNEL EQ '1' AND d_st_date_day EQ 'MON' OR 'TUES' OR 'WED' OR 'THU' OR 'FRI')
THEN VALUE ELSE 0;
-*
-*Weekend Usage
WKEND_USG/D20.2 = IF (UNIT_OF_MEASURE CONTAINS 'KWH' AND CHANNEL EQ '1' AND d_st_date_day EQ 'SAT' OR 'SUN')
THEN VALUE ELSE 0;
-*
-*Missing Intervals
MISS_INTVL/A3 = IF (KWH_VAL EQ MISSING AND KVH_VAL NE MISSING) OR (KWH_VAL NE MISSING AND KVH_VAL EQ MISSING) THEN 'NOP' ELSE 'YES';
-*MISS_INTVL/A3 = IF AMI_VENDOR_CODE EQ 'NISC_FAKE_READ' THEN 'NOP' ELSE 'YES';
-*
-*Notes
NOTES/A25 = IF (KWH_VAL EQ MISSING AND KVH_VAL NE MISSING) THEN 'Channel 1 partial data' ELSE
IF (KWH_VAL NE MISSING AND KVH_VAL EQ MISSING) THEN 'Channel 1 partial data' ELSE '';
-*START_DATE_MILLIS/P39 = START_DATE_MILLIS;
-*END_DATE_MILLIS/P39 = END_DATE_MILLIS;
END
SET MISSING = ON
TABLE FILE MDM_READINGS
SUM KVH_VAL
KWH_VAL
-* START_DATE_MILLIS
-* END_DATE_MILLIS
d_st_date_cvte_hmdyy
d_end_date_cvte_hmdyy
CHANNEL
UNIT_OF_MEASURE
TOT_USG
WKDY_USG
WKEND_USG
NOTES
BY AMI_METER_ID
-*BY d_st_date_cvtepoch
WHERE AMI_METER_ID EQ '135628301';
WHERE d_st_date_cvte_hmdyy GE '02/01/2017';
WHERE d_end_date_cvte_hmdyy LE '02/04/2017';
WHERE CHANNEL EQ '1' OR '1';
WHERE UNIT_OF_MEASURE CONTAINS 'KWH' OR 'KV';
WHERE MISS_INTVL EQ 'YES';
ON TABLE HOLD AS HOLDRPT FORMAT ALPHA
END
-RUN
(FOC822) VALID VALUES ARE MISSINGTEST=OLD SPECIAL
0 NUMBER OF RECORDS IN TABLE= 267 LINES= 1
-*Hold epoch dates
TABLE FILE MDM_READINGS
SUM START_DATE_MILLIS
END_DATE_MILLIS
BY AMI_METER_ID NOPRINT
WHERE AMI_METER_ID EQ '135628301';
WHERE d_st_date_cvte_hmdyy GE '02/01/2017';
WHERE d_end_date_cvte_hmdyy LE '02/04/2017';
WHERE CHANNEL EQ '1' OR '1';
WHERE UNIT_OF_MEASURE CONTAINS 'KWH' OR 'KV';
-*WHERE MISS_INTVL EQ 'YES';
ON TABLE HOLD AS HOLDDTS
END
-RUN
0 NUMBER OF RECORDS IN TABLE= 267 LINES= 1
-*Read epoch dates into amper variables
-SET &START_DATE_MILLIS = '';
-SET &END_DATE_MILLIS = '';
-BEGIN
(FOC2906) WARNING: &START_DATE_MILLIS WILL BE OVERWRITTEN BY -READFILE HOLDDTS
(FOC2906) WARNING: &END_DATE_MILLIS WILL BE OVERWRITTEN BY -READFILE HOLDDTS
-READFILE HOLDDTS
-TYPE 396774493200000
396774493200000
-TYPE 396774730800000
396774730800000
-DONE
-RUN
DEFINE FILE HOLDRPT
MIN_KW_DEM_2/D20.2 = 1.56 ;
MAX_KW_DEM_2/D20.2 = 10.86 ;
START_DATE_MILLIS/P33 = 396774493200000;
END_DATE_MILLIS/P33 = 396774730800000;
-*
-*D_START_DATE_MILLIS/I20 = EDIT(START_DATE_MILLIS);
-*D_END_DATE_MILLIS/I20 = EDIT(END_DATE_MILLIS);
-*H period
INTVL_HRS/I20 = (END_DATE_MILLIS - START_DATE_MILLIS) / 3600000;
-*INTVL_HRS/I20 = (D_END_DATE_MILLIS - D_START_DATE_MILLIS) / 3600000;
-*INTVL_HRS/I20 = (8000000000 - 4000000000) / 3600000;
-*
-*Load Factor Calculation - Will get from other pieces of the DEFINE
D_LF/D20.2 = MAX_KW_DEM_2 * INTVL_HRS;
LD_FACT/D20.2 = KWH_VAL / (MAX_KW_DEM_2 * INTVL_HRS);
-*
-*Avg Power Factor Calculation
POW_FACT/D20.2 = 1/SQRT(1+(KWH_VAL/KVH_VAL)*2); -*1st Formula
POW_FACT2/D20.2 = KVH_VAL/(SQRT(KWH_VAL*2+KVH_VAL*2)); -*2nd Formula
-*
-*Lagging or Leading Calculation for Power Factor
LAG_LEAD_PF/D20.2 = KWH_VAL/(SQRT(KWH_VAL*2+KVH_VAL*2));
LAG_LEAD_TEST/D20.2 = IF LAG_LEAD GE 0 THEN (POW_FACT * -1) ELSE POW_FACT;
END
TABLE FILE HOLDRPT
HEADING CENTER
"Min Max Summary"
PRINT KVH_VAL
KWH_VAL
INTVL_HRS
D_LF
MIN_KW_DEM_2 AS 'Minimum kW Demand'
MAX_KW_DEM_2 AS 'Maximum kW Demand'
LD_FACT AS 'Load Factor'
LAG_LEAD_TEST AS 'Average Power Factor'
TOT_USG AS 'Total Usage'
WKDY_USG AS 'Weekday Usage'
WKEND_USG AS 'Weekend Usage'
NOTES AS 'Notes'
BY AMI_METER_ID
-*BY d_st_date_cvtepoch
-*WHERE AMI_METER_ID EQ '&METER';
-*WHERE d_st_date_cvte_hmdyy GE '&ST_DT';
-*WHERE d_end_date_cvte_hmdyy LE '&END_DT';
-*WHERE CHANNEL EQ '&KW_CHANNEL' OR '&KV_CHANNEL';
-*WHERE UNIT_OF_MEASURE CONTAINS 'KWH' OR 'KV';
-*WHERE MISS_INTVL EQ 'YES';
ON TABLE PCHOLD FORMAT AHTML
ON TABLE NOTOTAL
ON TABLE SET AUTOFIT OFF
ON TABLE SET CACHELINES 100
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET SQUEEZE ON
ON TABLE SET HTMLCSS ON
ON TABLE SET HTMLENCODE ON
ON TABLE SET EMPTYREPORT ON
ON TABLE SET WEBVIEWTARG OFF
ON TABLE SET WEBVIEWER ON
ON TABLE SET GRWIDTH 1
ON TABLE SET STYLE *
ENDSTYLE
END
-RUN
(FOC1065) PROGRAM ERROR
-EXIT
WF 8.1.05
Windows
SQL Server 2014
HTML, PDF, EXCEL