Focal Point
Help- Trying to suppress the zeros for the day and Month.

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

August 12, 2008, 10:16 AM
Denny99
Help- Trying to suppress the zeros for the day and Month.
WebFocus's date formats attach a leading 0 for days (i.e. 1 thru 9) or months (1 thru 9). If I don't want these leading zeros how do I suppress them? For example, instead of 01/01/2008, I want 1/1/2008. Thanks a million Cool
August 12, 2008, 02:16 PM
Carol Dobson
What a shame that you have to tear apart a smart date, this should do it, but now you loose all the functionality of the smart dates!

DATE/MDYY 01012008 ;
ADATE/A8MDYY = DATE;
MONTH/A2 = EDIT(ADATE,'99$$$$$$');
IMONTH/I2S=EDIT(MONTH);
DAY/A2=EDIT(ADATE,'$$99$$$$');
IDAY/I2S = EDIT(DAY);
YEAR/A4 = EDIT(ADATE,'$$$$9999');
IYEAR/I4=EDIT(YEAR);
YOURDATE/A10 = EDIT(IMONTH) | '/' | EDIT(IDAY) | '/' |EDIT(IYEAR);

Lastly, please update your signiture so we can better help you.

Thank you.



WebFOCUS 7.6.6/TomCat/Win2k3
August 12, 2008, 02:37 PM
Francis Mariani
Unfortunately, this doesn't do it.

DEFINE FILE CAR
DATE/MDYY = 01012008 ;
ADATE/A8MDYY = DATE;
MONTH/A2 = EDIT(ADATE,'99$$$$$$');
IMONTH/I2S=EDIT(MONTH);
DAY/A2=EDIT(ADATE,'$$99$$$$');
IDAY/I2S = EDIT(DAY);
YEAR/A4 = EDIT(ADATE,'$$$$9999');
IYEAR/I4=EDIT(YEAR);
YOURDATE/A10 = EDIT(IMONTH) | '/' | EDIT(IDAY) | '/' |EDIT(IYEAR);
END

TABLE FILE CAR
PRINT
COUNTRY
DATE
YOURDATE
END


You still get the leading zeros because the S (zero suppress) in I2S is ignored when using EDIT - EDIT(IMONTH).

This message has been edited. Last edited by: Francis Mariani,


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
August 12, 2008, 02:47 PM
Francis Mariani
Extremely ugly, but this will do it:

DEFINE FILE CAR
DATE/MDYY = 01012008 ;
ADATE/A8MDYY = DATE;
AMONTH/A2    = EDIT(ADATE,'99$$$$$$');
IMONTH/F2    = EDIT(AMONTH);
FMONTH/A2    = FTOA(IMONTH, '(D2S)', FMONTH);
ADAY/A2      = EDIT(ADATE,'$$99$$$$');
IDAY/F2      = EDIT(ADAY);
FDAY/A2      = FTOA(IDAY, '(D2S)', FDAY);
AYEAR/A4     = EDIT(ADATE,'$$$$9999');
YOURDATE/A10 = STRIP(2, FMONTH, ' ', 'A2')|| '/' || STRIP(2, FDAY, ' ', 'A2')|| '/' || AYEAR;
YOURDATEX/A10 = FMONTH || '/' || FDAY || '/' || AYEAR;
END

TABLE FILE CAR
PRINT
COUNTRY
DATE
YOURDATE
YOURDATEX
END


FTOA converts the numeric field to alpha, respecting the zero suppress. YOURDATEX is here to illustrate my puzzlement as to why the hard concatenation doesn't work with FMONTH and FDAY without the STRIP function.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
August 12, 2008, 03:00 PM
Carol Dobson
You're right Francis, thanks for the correction in the ugly code! Eeker Brings back the old days coding memories.

I'd vote to keep the leading zeros and smart date format myself.



WebFOCUS 7.6.6/TomCat/Win2k3
August 12, 2008, 03:38 PM
Jud
DEFINE FILE GEORGE
FRED/MDYY = 01012008;
FOO/A10 = DATETRAN(FRED, '(MDYY)', '(dm/)', 'EN', 10, 'A10');

...
August 12, 2008, 03:48 PM
Francis Mariani
Jud,

Thank you - you've trumped us!
DATETRAN Function: Formatting Dates in International Formats was added in v7.

One day my client will upgrade...


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
August 12, 2008, 04:35 PM
Carol Dobson
Jud, that's much better! Good One



WebFOCUS 7.6.6/TomCat/Win2k3
August 12, 2008, 04:36 PM
Prarie
I had a feeling it was out there...just couldn't find it...Thanks. What version you have Denny?


In Focus since 1993. WebFOCUS 7.7.03 Win 2003