Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only. Moving forward, myibi is our community platform to learn, share, and collaborate. We have the same Focal Point forum categories in myibi, so you can continue to have all new conversations there. If you need access to myibi, contact us at myibi@ibi.com and provide your corporate email address, company, and name.


Connect to myibi
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     (SOLVED) Date Conversion

Read-Only Read-Only Topic
Go
Search
Notify
Tools
(SOLVED) Date Conversion
 Login/Join
 
Gold member
posted
Hi All,

I am kind of struck in the middle for this date conversion.

I am getting my last week's end of week date and last week's beginning of week date from the following code.

 
-SET &LW=DATEADD(DATECVT(AYMD(&YYMD,-7,'I8MDYY'),'I8YYMD','YYMD'),'D',0);
-SET &LW_EOW=DATECVT(DATEADD(DATEMOV(&LW,'EOW'),'D','1'),'YYMD','I8MDYY');
-SET &LW_BOW=DATECVT(DATEADD(DATEMOV(&LW,'BOW'),'D','-1'),'YYMD','I8MDYY');
 


It gives me the following values
LW_EOW = 1142017
LW_BOW = 1082017

I want to convert this date to MM/DD/YYYY like 01/14/2017 or 01/08/2017

For Oct - Dec i used to run the following code and it was working fine.

-SET &LW_EOW_DATE = EDIT(&LW_EOW, '99$')|'/'| EDIT(&LW_EOW, '$$99')|'/' | EDIT (&LW_EOW, '$$$$9999');

For Month it returns just the single digit for Jan-Sep (1-9).
So i added a 0 in the following EDIT function
and it does the trick.

-SET &LW_EOW_DATE = EDIT(&LW_EOW, '09$')|'/'| EDIT(&LW_EOW, '$99')|'/' | EDIT (&LW_EOW, '$$$9999');

But is there any way i can do it without hardcoding the value 0 in front of month's value?

I know it might be simple but i cant figure out. Any help would be appreciated.

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


Tharun Katanguru
SBOX- 8205 DEV/TEST/PROD : 8105 8205
Linux, All Outputs
 
Posts: 52 | Location: BOWL OF PASTA | Registered: October 13, 2016Report This Post
Expert
posted Hide Post
-SET &LW     = DATECVT( DATEADD( DATECVT(&YYMD,'I8YYMD','YYMD') ,'D', -7), 'YYMD','I8YYMD');
-SET &LW_BOW = DATECVT( DATEMOV( DATECVT(&LW,'I8YYMD','YYMD') ,'BOW'),'YYMD','I8YYMD');
-SET &LW_EOW = DATECVT( DATEMOV( DATECVT(&LW,'I8YYMD','YYMD') ,'EOW'),'YYMD','I8YYMD');

-? &LW

The inner DATECVT converts a string to a date. Then the DATEADD/DATEMOVE function is applied. Then the outer DATECVT converts the resulting date back to a string.

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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Platinum Member
posted Hide Post
Francis beat me to it. That inner DATECVT is what you are missing.


JC
WebFOCUS Dev Studio / App Studio
8.2.01
Windows 7
 
Posts: 146 | Registered: November 09, 2015Report This Post
Gold member
posted Hide Post
Arghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh!!!

Got it to work.

-SET &LW = DATECVT( DATEADD( DATECVT(&YYMD,'I8YYMD','YYMD') ,'D', -7), 'YYMD','I8YYMD');
-SET &LW_BOW = DATECVT(DATEADD( DATEMOV( DATECVT(&LW,'I8YYMD','YYMD') ,'BOW'),'D','-1'),'YYMD','I8YYMD');
-SET &LW_EOW = DATECVT(DATEADD( DATEMOV( DATECVT(&LW,'I8YYMD','YYMD') ,'EOW'),'D','1'),'YYMD','I8YYMD');

-SET &LW_EOW_DATE = EDIT(&LW_EOW, '$$$$99')|'/'| EDIT(&LW_EOW, '$$$$$$99')|'/' | EDIT (&LW_EOW, '9999$');
-SET &LW_BOW_DATE = EDIT(&LW_BOW, '$$$$99')|'/'| EDIT(&LW_BOW, '$$$$$$99')|'/' | EDIT (&LW_BOW, '9999$');

Thanks for the input Francis & jcannavo. I really admire your Knowledge and service to the WF Community.


Tharun Katanguru
SBOX- 8205 DEV/TEST/PROD : 8105 8205
Linux, All Outputs
 
Posts: 52 | Location: BOWL OF PASTA | Registered: October 13, 2016Report This Post
Master
posted Hide Post
@Francis - Loved the way you highlighted the three functions; to help show that/how they are interrelated.
 
Posts: 822 | Registered: April 23, 2003Report This Post
Expert
posted Hide Post
Thanks David. Not something you can find in the functions manual.


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Virtuoso
posted Hide Post
As I suggested in another post Let's Date :
all this converting should be much simplified!


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Expert
posted Hide Post
It appears IBI is making an attempt at simplifying date functions:

In the documentation WebFOCUS Release 8.1 Version 05M > Reporting Language > Using Functions > Simplified Date and Date-Time Functions, it is explained:

quote:
Simplified date and date-time functions have streamlined parameter lists, similar to those used by SQL functions. In some cases, these simplified functions provide slightly different functionality than previous versions of similar functions.
The simplified functions do not have an output argument. Each function returns a value that has a specific data type.
When used in a request against a relational data source, these functions are optimized (passed to the RDBMS for processing).
Standard date and date-time formats refer to YYMD and HYYMD syntax (dates that are not stored in alphanumeric or numeric fields). Dates not in these formats must be converted before they can be used in the simplified functions. Literal date-time values can be used with the DT function.
All arguments can be either literals, field names, or amper variables.
Note: The simplified date and date-time functions are not supported in WebFOCUS Maintain.

From this description, it appears strings can be used in the functions. We're on ancient v8.0.08 so I haven't tested the benefits of these newish "simplified" functions.


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     (SOLVED) Date Conversion

Copyright © 1996-2020 Information Builders