Focal Point
[SOLVED] Dialogue Manager - Date to I8MDYY not working

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

September 08, 2017, 05:33 PM
cldiaz
[SOLVED] Dialogue Manager - Date to I8MDYY not working
I've searched the forum, documentation and 1001 ways to work with dates and can't find the answer so I'm hoping someone will have some advice for me.

 -SET &INPUT_DATE = &YYMD;
-SET &DATECVT = DATECVT (&INPUT_DATE, 'I8YYMD', 'YYMD');
-SET &DATEADD = DATEADD(&DATECVT, 'D', '-9');
-SET &LAST_WEEK_MDYY = DATECVT (&DATEADD, 'YYMD', 'I8MDYY');
-SET &LAST_WEEK_YYMD = DATECVT (&DATEADD, 'YYMD', 'I8YYMD');

-TYPE LastWeek_MDYY = &LAST_WEEK_MDYY
-TYPE LastWeek_YYMD = &LAST_WEEK_YYMD 


For the I8MDYY value I get 8302017, I'm looking to get 08302017. When I do this I8YYMD, I get 20170830. I must be missing something but can't figure out what it is! Any advice is appreciated!

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


WebFOCUS 8204
Windows, All Outputs
September 11, 2017, 08:36 AM
MartinY
quote:

For the I8MDYY value I get 8302017


Format I8 is an Integer, a numeric value. Left side zero (0) are useless in numeric representation. So while the month will be below 10, you won't have it display as 08302017.


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
September 11, 2017, 08:39 AM
BabakNYC
If you need the 0 for display consistency, you can convert the Integer to an Alpha using this code:

 -SET &LAST_WEEK_MDYY=IF &LAST_WEEK_MDYY.LENGTH LE 7 THEN '0'||&LAST_WEEK_MDYY ELSE &LAST_WEEK_MDYY; 



WebFOCUS 8206, Unix, Windows
September 11, 2017, 09:23 AM
jfr99
-*
-SET &LAST_WEEK_I8MDYY = DATECVT((DATEADD((DATECVT (&YYMD, 'I8YYMD', 'YYMD')),'D', -07)), 'YYMD','I8MDYY');
-SET &LAST_WEEK_A8MDYY = DATECVT((DATEADD((DATECVT (&YYMD, 'I8YYMD', 'YYMD')),'D', -07)), 'YYMD','A8MDYY');
-*
-TYPE LAST_WEEK_I8MDYY -------- &LAST_WEEK_I8MDYY
-TYPE LAST_WEEK_A8MDYY -------- &LAST_WEEK_A8MDYY


WebFocus 8.201M, Windows, App Studio
September 11, 2017, 02:21 PM
cldiaz
Thanks all of you! Based on the advice I just changed my format to an A8MDYY instead of I8MDYY and it now works as expected.


WebFOCUS 8204
Windows, All Outputs
September 12, 2017, 08:49 AM
jgelona
cldiaz, here's why that worked. You have to remember that in Dialogue Manager, every variable is an alphanumeric string. However, when you specified a I8MDYY format, and since the variable was all numbers, DM treated it like a integer and trimmed the leading zero. Using A8MDYY left the leading zero. When I see issues on here about DM, a great deal of the time it is because the person asking the question doesn't know or has never been told that all local and global variables are alphanumeric strings.


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