Focal Point
Formatting Parameter

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

May 01, 2006, 04:49 PM
Nailzz
Formatting Parameter
Good afternoon all, I am trying to set a parameter that gives me a date using a year back. This is the code I have. However, for my NEWEND it is giving me 20050995 in stead of 20060601. Can someone tell me how I can get this to work?

-SET &BSTART =1;
-SET &BEND =1;
-*-THIS IS TO GET THE QTC RECORDS
-SET &OFFSET = IF &MONTH EQ 01 OR 04 OR 07 OR 10 THEN -2 ELSE 99;
-SET &OFFSET = IF &MONTH EQ 02 OR 05 OR 08 OR 11 THEN -1 ELSE 99;
-SET &OFFSET = IF &MONTH EQ 03 OR 06 OR 09 OR 12 THEN 0 ELSE 99;

-SET &OFFSET2 = IF &MONTH EQ 01 OR 04 OR 07 OR 10 THEN 12 ELSE 99;
-SET &OFFSET2 = IF &MONTH EQ 02 OR 05 OR 08 OR 11 THEN 11 ELSE 99;
-SET &OFFSET2 = IF &MONTH EQ 03 OR 06 OR 09 OR 12 THEN 10 ELSE 99;

-*SET &BSTART=&PBSTART;
-*SET &PB = &BSTART;
-SET &PB = &BSTART + &OFFSET;
-MRNOEDIT -INCLUDE SDRYYMD
-SET &BEG1 = &BEGMTH_YYMD;
-*SET &BEND = &PBEND;
-*SET &PB = &BEND;
-SET &PB = &BEND + &OFFSET2;
-MRNOEDIT -INCLUDE SDRYYMD
-SET &ENDDATE = &ENDMTH_YYMD;
-SET &ENMNTH = EDIT(&ENDDATE,'$$$$99$$');
-SET &ENYEAR = EDIT(&ENDDATE,'9999$$$$');
-SET &ENDAYYEAR = IF (ENYEAR EQ '2003' OR '2007') AND (ENMNTH GT '02') THEN 366 ELSE 365;
-SET &NEWEND = &ENDAYYEAR + &ENDDATE;
-*SET &END1 = &NEWEND;


WebFOCUS 7.1.3 on Win 2000
May 01, 2006, 05:14 PM
reFOCUSing
It's a little hard to debug your code since you don't state what the input values are and what is the code in the SDRYYMD file?

Have you tried using the DATEMOV or DATEADD functions? They maybe what you are looking for to make your code a lot easier.

Here are links to doc's on the tech support site:
http://documentation.informationbuilders.com/masterinde...t_520/datetime11.htm
http://documentation.informationbuilders.com/masterinde...ctions713/datea4.htm

This message has been edited. Last edited by: reFOCUSing,
May 01, 2006, 05:23 PM
Nailzz
Thanks, I will look at this.

Actually the SDRYYMD file is just dates formated for days, month, fiscal year. This allows me to say where PB + 3 (period back) for three days back, 3 months back, etc). Unfortunately it does not have "future" dates in which I need for a as of date range period for 04/01/2006 that will end on 06/30/2006.


WebFOCUS 7.1.3 on Win 2000
May 01, 2006, 05:43 PM
reFOCUSing
I did something like what you are doing a couple years ago. Give this code a try and see if it works.

-* Name         : Date Definition Setup
-* Product      : WebFOCUS
-* Executed     : on request
-* Created by   : reFOCUSing
-* Created on   : June 28/2004
-* Parameters   :
-*    &TIME_TYPE: Can have the value of 'YEAR', 'QUARTER', 'MONTH', 'WEEK' or 'DAY'
-*    &TIME_DRCT: Can have the value of 'FRWD' or 'BACK'
-*    &TIME_STRT: 0 to x.
-*    &TIME_DURA: 0 to x.
-* Output file  : none
-* Description  :
-*    This is the variable setup for the dates that will be used in WHERE
-*     statements and any other commonly used variables in reports.
-* Maintenance  :
-*   June 28 File created.
-*
-***********VARIALBES***********************************************

-* Initializing procedure.
-DEFAULT &TIME_TYPE = 'MONTH'
-DEFAULT &TIME_DRCT = 'FRWD'
-DEFAULT &TIME_STRT = 4
-DEFAULT &TIME_DURA = 2

-* Display unformatted user input.
-TYPE Unformated User Inputs:
-TYPE TIME_TYPE '&TIME_TYPE', TIME_DRCT '&TIME_DRCT'
-TYPE TIME_STRT '&TIME_STRT', TIME_DURA '&TIME_DURA'
-RUN

-* Error checking.
-* Checking the input of &TIME_TYPE.
-* Change text to uppercase.
-* The default is DAY.
-SET &LEN = '''A' | &TIME_TYPE.LENGTH | '''';
-SET &TIME_TYPE = UPCASE(&TIME_TYPE.LENGTH, &TIME_TYPE, &LEN.EVAL);
-SET &TIME_TYPE =
-IF '&TIME_TYPE.EVAL' EQ 'YEAR' OR 'QUARTER' OR 'MONTH' OR 'WEEK' OR 'DAY'
-  THEN &TIME_TYPE
-ELSE 'DAY';
-RUN

-* Checking the input of &TIME_DRCT.
-* Change text to uppercase
-* The default is BACK.
-SET &LEN = '''A' | &TIME_DRCT.LENGTH | '''';
-SET &TIME_DRCT = UPCASE(&TIME_DRCT.LENGTH, &TIME_DRCT, &LEN.EVAL);
-SET &TIME_DRCT =
-IF '&TIME_DRCT.EVAL' EQ 'BACK' OR 'FRWD'
-  THEN &TIME_DRCT
-ELSE 'BACK';
-RUN

-* Checking the input of &TIME_STRT.
-* The default is 0.
-SET &TIME_STRT =
-IF ASIS(&TIME_STRT) LT 0 OR &TIME_STRT.TYPE EQ 'A' THEN 0 ELSE &TIME_STRT;
-SET &TIME_STRT =
-IF '&TIME_DRCT.EVAL' EQ 'BACK' THEN -&TIME_STRT ELSE &TIME_STRT;
-RUN

-* Checking the input of &TIME_DURA.
-* The default is 1.
-SET &TIME_DURA =
-IF ASIS(&TIME_DURA) LT 1 OR &TIME_DURA.TYPE EQ 'A' THEN 1 ELSE &TIME_DURA;
-RUN

-* GOTO specific date creation.
-GOTO :SET_&TIME_TYPE

-:SET_YEAR
-***********SET YEAR************************************************
-* Set the Start and End date for YEAR.
-* Default date is today.
-SET &DT = AYMD(&YYMD,0,'I8');
-* Change value to work with date manipulation.
-SET &TIME_DURA = &TIME_DURA - 1;
-* Produce the start date and end date.
-SET &START_YYMD = DATECVT((DATEMOV((DATEADD((DATECVT(&DT,'I8YYMD','YYMD')),'Y',&TIME_STRT)),'BOY')),'YYMD','I8YYMD');
-SET &END_YYMD = DATECVT((DATEMOV((DATEADD((DATECVT(&START_YYMD,'I8YYMD','YYMD')),'Y',&TIME_DURA)),'EOY')),'YYMD','I8YYMD');
-RUN
-GOTO :SET_TIME

-:SET_QUARTER
-**********SET QUARTER*********************************************
-* Set the Start and End date for QUARTER.
-* Default date is today.
-SET &DT = AYMD(&YYMD,0,'I8');
-* Change value to work with date manipulation.
-SET &TIME_STRT = &TIME_STRT * 3;
-SET &TIME_DURA = (&TIME_DURA - 1) * 3;
-* Produce the start date and end date.
-SET &START_YYMD = DATECVT((DATEMOV(DATEADD((DATECVT(&DT,'I8YYMD','YYMD')),'M',&TIME_STRT),'BOQ')),'YYMD','I8YYMD');
-SET &END_YYMD = DATECVT((DATEMOV(DATEADD((DATECVT(&START_YYMD,'I8YYMD','YYMD')),'M',&TIME_DURA),'EOQ')),'YYMD','I8YYMD');
-RUN
-GOTO :SET_TIME

-:SET_MONTH
-**********SET MONTH***********************************************
-* Set the Start and End date for MONTH.
-* Default date is today.
-SET &DT = AYMD(&YYMD,0,'I8');
-* Change value to work with date manipulation.
-SET &TIME_DURA = &TIME_DURA - 1;
-* Produce the start date and end date.
-SET &START_YYMD = DATECVT((DATEMOV(DATEADD((DATECVT(&DT,'I8YYMD','YYMD')),'M',&TIME_STRT),'BOM')),'YYMD','I8YYMD');
-SET &END_YYMD = DATECVT((DATEMOV(DATEADD((DATECVT(&START_YYMD,'I8YYMD','YYMD')),'M',&TIME_DURA),'EOM')),'YYMD','I8YYMD');
-RUN
-GOTO :SET_TIME

-:SET_WEEK
-**********SET WEEK************************************************
-* Set the Start and End date for WEEK
-* Default date is today.
-SET &DT = AYMD(&YYMD,0,'I8');
-* Change value to work with date manipulation.
-SET &TIME_STRT = &TIME_STRT * 7;
-SET &TIME_DURA = IF &TIME_DURA LT 1 THEN 6 ELSE (&TIME_DURA  * 7) - 1;
-SET &FIRST_W_D = DOWK(&DT, 'A3');
-SET &FIRST_W_D = DECODE &FIRST_W_D(
- 'SUN' '0' 'MON' '1' 'TUE' '2' 'WED' '3' 'THU' '4' 'FRI' '5' 'SAT' '6');
-SET &DT = AYMD(&DT, -&FIRST_W_D, 'I8');
-* Produce the start date and end date.
-SET &START_YYMD = AYMD(&DT, &TIME_STRT, 'I8');
-SET &END_YYMD = AYMD(&START_YYMD, &TIME_DURA, 'I8');
-RUN
-GOTO :SET_TIME

-:SET_DAY
-**********SET DAY*************************************************
-* Set the Start and End date for DAY.
-* Default date is today.
-SET &DT = AYMD(&YYMD,0,'I8');
-* Change value to work with date manipulation.
-SET &TIME_DURA = &TIME_DURA - 1;
-* Produce the start date and end date.
-SET &START_YYMD = AYMD(&DT,&TIME_STRT,'I8');
-SET &END_YYMD = AYMD(&START_YYMD,&TIME_DURA,'I8');
-RUN
-GOTO :SET_TIME

-:SET_TIME
-**********SET TIME************************************************
-* Set the time used.
-* Error check for Date.
-SET &DT = AYMD(&YYMD,0,'I8');
-SET &END_YYMD =
-IF &TIME_DRCT EQ 'BACK' AND &END_YYMD GT &DT THEN &DT ELSE &END_YYMD;
-* Creating other date variables.
-SET &START_YYMD_T = EDIT(&START_YYMD, '9999/99/99') | ' 00:00:00';
-SET &END_YYMD_T   = EDIT(&END_YYMD, '9999/99/99') | ' 23:59:59';
-SET &START_MDYY = EDIT(&START_YYMD, '$$$$9999') | EDIT(&START_YYMD, '9999');
-SET &END_MDYY = EDIT(&END_YYMD,  '$$$$9999') | EDIT(&END_YYMD, '9999');
-RUN

-**********FORMATTED VARIABLES*************************************
-* Display formatted variables.
-TYPE Formatted variables:
-TYPE Start Date &START_YYMD, &START_YYMD_T, &START_MDYY
-TYPE End   Date &END_YYMD, &END_YYMD_T, &END_MDYY
-RUN

This message has been edited. Last edited by: reFOCUSing,
May 01, 2006, 05:43 PM
Nailzz
I changed my code since I am only trying to generate and enddate and this gives me what I needed. Thanks!

-SET &ENDDAY = EDIT(&ENDDATE,'$$$$$$99');
-SET &ENMNTH = EDIT(&ENDDATE,'$$$$99$$');
-SET &ENYEAR = EDIT(&ENDDATE,'9999$$$$');
-SET &ENDYEAR = &ENYEAR + 1;
-SET &NEWEND = &ENDYEAR||&ENMNTH||&ENDDAY;
-SET &END1 = &NEWEND;


WebFOCUS 7.1.3 on Win 2000