Focal Point
[SOLVED] previous month in master file

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

September 05, 2012, 12:10 PM
Peter
[SOLVED] previous month in master file
Hi, for comparison reasons I'm trying to get an integer field containing the previous month in a master file (201208 if we're September)

Although it sounds simple enough I just can't find it!

original idea:
DEFINE PREVMON/I6=EDIT(DATECVT(DATEADD(&YYMD,'M',-1),'YYMD','YYM'))

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


Prod: WebFOCUS 8.0.06 on Win2008/Tomcat7/LDAP Mode
Test: WebFOCUS 8.0.06 on Win2008/Tomcat7/LDAP Mode
September 05, 2012, 02:10 PM
Prarie
DEFINE FILE CAR
TODAY/YYMD = &YYMD;
PRIOR_MO/YYMD=DATEADD(TODAY,'M',-1);
PRIORM/M = PRIOR_MO;
PRIORY/MYY = PRIOR_MO
END
TABLE FILE CAR
PRINT CAR TODAY  PRIOR_MO PRIORM PRIORY
END 

September 05, 2012, 04:54 PM
Alan B
To get this as an integer is not so straight forward, but in an MFD you can try:
DEFINE THISMON/YYMD='&YYMD';,ACCESS_PROPERTY=(INTERNAL),$
DEFINE LSTMON/YYM=DATEADD(THISMON,'M',-1);,ACCESS_PROPERTY=(INTERNAL),$
DEFINE INTMON/I6YYM=LSTMON;,ACCESS_PROPERTY=(INTERNAL),$
DEFINE PREVMON/I6=INTMON;,$

There may be a slightly easier approach, but can't think now.


Alan.
WF 7.705/8.007
September 05, 2012, 05:48 PM
Dan Satchell
Or this....

PREV_YYM/A6YYM = DATEADD('&YYMD','M',-1);
PREV_MONTH/I6  = EDIT(PREV_YYM);



WebFOCUS 7.7.05
September 06, 2012, 03:14 AM
Peter
Thanks all for the suggestions.
Although all of the above solutions probably work in a fex, they don't seem to work in a master file...


Prod: WebFOCUS 8.0.06 on Win2008/Tomcat7/LDAP Mode
Test: WebFOCUS 8.0.06 on Win2008/Tomcat7/LDAP Mode
September 06, 2012, 03:26 AM
Alan B
quote:
DEFINE THISMON/YYMD='&YYMD';,ACCESS_PROPERTY=(INTERNAL),$
DEFINE LSTMON/YYM=DATEADD(THISMON,'M',-1);,ACCESS_PROPERTY=(INTERNAL),$
DEFINE INTMON/I6YYM=LSTMON;,ACCESS_PROPERTY=(INTERNAL),$
DEFINE PREVMON/I6=INTMON;,$


Will work in an MFD. Have you tried it?


Alan.
WF 7.705/8.007
September 06, 2012, 05:31 AM
Peter
@Alan, you're absolutely right!
It did work from the start, but I got an error related to something else.

Thanks a bunch for this - it's a pity so many defines need to be created as it can't be done in a single pass.
(which was my mistake at first)


Prod: WebFOCUS 8.0.06 on Win2008/Tomcat7/LDAP Mode
Test: WebFOCUS 8.0.06 on Win2008/Tomcat7/LDAP Mode