Focal Point
[SOLVED] Month of Current Date is blank

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

October 07, 2019, 09:07 AM
RobertF
[SOLVED] Month of Current Date is blank
testing wf8206.

Essentially I need to evaluate today's date and if July (7/07??) then set a variable to TRUE otherwise FALSE.

I was able to find a function to return the current date's month. See Below. The trouble is that when I run my fex...it is always blank.

Ideas?

After that works, I must somehow code my where to say, in English..if I'm in July (CURMTH=7)then select rollingmonths = 0 or -1 or -2 otherwise just select rollingmonths = 0 or -1.


-* Get Month of Current Date
DEFINE FILE TBLMSTR_CALENDARPERIOD
CURMTH/M=DT_CURRENT_DATE();
END

TABLE FILE TBLMSTR_CALENDARPERIOD
BY LOWEST TBLMSTR_CALENDARPERIOD.TBLMSTR_CALENDARPERIOD.FISCALYEAR
BY LOWEST TBLMSTR_CALENDARPERIOD.TBLMSTR_CALENDARPERIOD.PERIOD
BY LOWEST TBLMSTR_CALENDARPERIOD.TBLMSTR_CALENDARPERIOD.PERIODTEXT
BY CURMTH
-* Eventually change WHERE below: In August Pull Rolling Months 0, -1, -2
-* Otherwise only pull RollingMonths 0, -1
WHERE TBLMSTR_CALENDARPERIOD.TBLMSTR_CALENDARPERIOD.ROLLINGMONTHS EQ 0 OR -1;
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET ASNAMES ON
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLEMBEDIMG ON
ON TABLE SET HTMLCSS ON
END

This message has been edited. Last edited by: FP Mod Chuck,


WebFOCUS 8206.08
Windows, All Outputs
October 07, 2019, 10:19 AM
RobertF
so here is where I am at...but the darn CURMTH is always blank!
(and I know I am using Oct (10) for testing--it should be 07..just want to make sure it works)


-* Get Month of Current Date
DEFINE FILE TBLMSTR_CALENDARPERIOD
CURMTH/M=DT_CURRENT_DATE();
FLAG/A1=IF CURMTH EQ '10' THEN 'T' ELSE 'F';
END
TABLE FILE TBLMSTR_CALENDARPERIOD
BY LOWEST TBLMSTR_CALENDARPERIOD.TBLMSTR_CALENDARPERIOD.FISCALYEAR
BY LOWEST TBLMSTR_CALENDARPERIOD.TBLMSTR_CALENDARPERIOD.PERIOD
BY LOWEST TBLMSTR_CALENDARPERIOD.TBLMSTR_CALENDARPERIOD.PERIODTEXT
BY LOWEST CURMTH
BY FLAG

-IF FLAG = 'T' THEN GOTO JULYWHERE ELSE GOTO OTHERWHERE;

-JULYWHERE
WHERE TBLMSTR_CALENDARPERIOD.TBLMSTR_CALENDARPERIOD.ROLLINGYEARS EQ 1 OR 0 OR -1;
-GOTO CONTINUE

-OTHERWHERE
WHERE TBLMSTR_CALENDARPERIOD.TBLMSTR_CALENDARPERIOD.ROLLINGYEARS EQ 0 OR -1;

-CONTINUE
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET ASNAMES ON
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLEMBEDIMG ON
ON TABLE SET HTMLCSS ON
END


WebFOCUS 8206.08
Windows, All Outputs
October 07, 2019, 11:35 AM
FP Mod Chuck
Robert

Since you date table seems to be having an issue how about trying this.

-SET &MONTH=EDIT(&YYMD,'$$$$99');
DEFINE FILE TBLMSTR_CALENDARPERIOD
CURMTH/I2=&MONTH;
FLAG/A1=IF CURMTH EQ '10' THEN 'T' ELSE 'F';
END

This message has been edited. Last edited by: FP Mod Chuck,


Thank you for using Focal Point!

Chuck Wolff - Focal Point Moderator
WebFOCUS 7x and 8x, Windows, Linux All output Formats
October 07, 2019, 12:48 PM
BabakNYC
Or try this:
  
CURRDT/YYMD=DT_CURRENT_DATE();
CURR_MNT/M=CURRDT;



WebFOCUS 8206, Unix, Windows
October 08, 2019, 09:02 AM
dbeagan
You could set a variable:

-SET &Roll07 = IF &DATEM EQ 7 THEN 'OR -2' ELSE ' ';

Then in your WHERE statement:

WHERE TBLMSTR_CALENDARPERIOD.TBLMSTR_CALENDARPERIOD.ROLLINGMONTHS EQ 0 OR -1 &Roll07;

You can use this set statement at the beginning of your procedure for testing:

 SET TESTDATE=20190701
-RUN



WebFOCUS 8.2.06
October 09, 2019, 07:29 AM
Frans
You need to truncate the date first:

 
DEFINE FILE CAR
CURMTH/M=DTRUNC(DT_CURRENT_DATE(),MONTH);
END

TABLE FILE CAR
BY LOWEST COUNTRY
BY LOWEST MODEL
BY LOWEST SEATS
BY CURMTH

ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET ASNAMES ON
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLEMBEDIMG ON
ON TABLE SET HTMLCSS ON
END
 



Test: WF 8.2
Prod: WF 8.2
DB: Progress, REST, IBM UniVerse/UniData, SQLServer, MySQL, PostgreSQL, Oracle, Greenplum, Athena.
October 09, 2019, 07:36 AM
Frans
And the date selection can be done like this:

 
DEFINE FILE CAR
CURMTH/M=DTRUNC(DT_CURRENT_DATE(),MONTH);
STARTMONTH/I1=IF CURMTH EQ 7 THEN -2 ELSE -1;
END

TABLE FILE CAR
BY LOWEST COUNTRY
BY LOWEST MODEL
BY LOWEST SEATS
BY CURMTH
BY STARTMONTH

-* SEATS will be the ROLLINGMONTHS, in your case the value will be 0
WHERE SEATS LE 5
WHERE SEATS GE STARTMONTH
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET ASNAMES ON
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLEMBEDIMG ON
ON TABLE SET HTMLCSS ON
END
 



Test: WF 8.2
Prod: WF 8.2
DB: Progress, REST, IBM UniVerse/UniData, SQLServer, MySQL, PostgreSQL, Oracle, Greenplum, Athena.
October 09, 2019, 01:24 PM
Edward Wolfgram
Just to clarify, it's important to remember the difference between new dates and datetimes. For instance, the function DT_CURRENT_DATE returns a *datetime* not a newdate. So, normally one would code:

MYDTIME/HYYMDS = DT_CURRENT_DATE();

To obtain the datetime, and then

MYMON/M = MYDTIME;

to get the *newdate* (M). Also, remember that automatic conversion from a datetime to a newdate is relatively new, starting with 7.7.6. Before this, one would need a datetime function to get the month value directly from a datetime. Also, two steps are needed to get the newdate (M) from a datetime: the following (currently) does not work:

MYMON/M = DT_CURRENT_DATE();

Now, as noted by others here, *unless you really need a datetime* you should not use DT_CURRENT_DATE(). The simplest way to get the current month is to just use the system variable &DATEM:

MYMON/M = &DATEM;

In the old days, &DATEM did not exist, and so one would code:

MYTODAY/YYMD = &YYMD;
MYTODM/M WITH COUNTRY = MYTODAY ;

Finally, remember that the M newdate is not really a date but rather a date component. It's just that the expression compiler knows how to extract date components without calling a subroutine:

MYTODAY/YYMD = &YYMD ;
MYTODD/D WITH COUNTRY = MYTODAY ;
MYTODM/M WITH COUNTRY = MYTODAY ;
MYTODY/YY WITH COUNTRY = MYTODAY ;


IBI Development
October 09, 2019, 01:37 PM
Frans
Good one about &DATEM, why is this parameter not listed if you do

-? &



Test: WF 8.2
Prod: WF 8.2
DB: Progress, REST, IBM UniVerse/UniData, SQLServer, MySQL, PostgreSQL, Oracle, Greenplum, Athena.
October 10, 2019, 08:43 AM
jgelona
quote:
Originally posted by Frans:
Good one about &DATEM, why is this parameter not listed if you do

-? &

Probably because you can put any valid date format after &DATE, i.e. &DATEY, &DATEYY, &DATED, &DATEMDYY, &DATEYYMD, &DATEMtRDYY, &DATEMtDYY, &DATEMTrDYY, &DATEW, &DATEQ, etc.

This message has been edited. Last edited by: jgelona,


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.