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.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Date issues with SQL passthru and -READ file statement

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Date issues with SQL passthru and -READ file statement
 Login/Join
 
Platinum Member
posted
Hello,

I know there are some threads on this forum already with the issue I am facing, I tried to go thru them but couldn't find a solution that solved my problem Frowner

I am using a SQL passthru query in WebFocus, saving it with ON TABLE SAVE AS and then reading the contents of that file using -READ statement. The date field in my Oracle database is of DATE datatype.

When I write the SQL as:
SELECT mydate from my table;

and then save the results and READ from it, the mydate field is of the format YYYYMMDD (By the way I have to use this field as a variable in one of my headings on the report, so I use the variable I READ into from the SQL)

Since I want the Date to be displayed in MM/DD/YYYY format, I changed my SQL to:
SELECT TO_CHAR(mydate, 'MM/DD/YYYY') and then the date comes up with 000010MM/DD/YYYY

I am not sure why those 1st 6 characters appear in my datefield... I tried TRUNC, TO_DATE, TRIM and everything else I could think of, but nothing helps me to display MM/DD/YYYY... How do I get rid of those 1st 6 characters?

What am I doing wrong?

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


WF 7.7.03, Win 7
 
Posts: 127 | Registered: January 12, 2017Report This Post
Expert
posted Hide Post
If only the whole world used YYYYMMDD...

The quickest way to convert a date variable is to use the CHGDAT function.

In your case, I'd leave the SQL column in YYYYMMDD format and use Dialogue Manager to convert the variable, as in this example (ignore the TABLE FILE):

DEFINE FILE CAR
DATE1/YYMD = '2016/04/24';
END

TABLE FILE CAR
SUM
DATE1
BY COUNTRY NOPRINT
ON TABLE SAVE AS HDATE1
END
-RUN

-READ HDATE1 &DATE1.A8.

-SET &DATE1A = CHGDAT('YYMD','MDYY',&DATE1,'A10');


-TYPE &DATE1 &DATE1A


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
Thanks Francis for your help!

CHGDAT helped me change the display format like I wanted, but I can't get it to display '/' in the date to separate month from day from year.. Basically I am looking to display the date as 11/11/2015 (as example)..

I can't use the DEFINE statement since it defaults my date to 2016/04/24 ... but my date will be dynamic based on the query result...

Thanks again!


WF 7.7.03, Win 7
 
Posts: 127 | Registered: January 12, 2017Report This Post
Expert
posted Hide Post
The DEFINE in my code is just an example - it's a way for me to get a DATE into my request. Please post some code so that we may help you further...


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
I have to display DATE1A in a text field defined later... in the format MM/DD/YYYY

DEFINE FILE CAR
DATE1/YYMD = '2016/04/24';
END

TABLE FILE CAR
SUM
DATE1
BY COUNTRY NOPRINT
ON TABLE SAVE AS HDATE1
END
-RUN

-READ HDATE1 &DATE1.A8.

-SET &DATE1A = CHGDAT('YYMD','MDYY',&DATE1,'A10');

DEFINE FILE CAR
TEXT1/A50 WITH MODEL = 'Effective Date of Contract: &DATE1A';
END



When I do this it displays my date as MMDDYYYY (11012015 for example) but I want it to display with the '/' as 11/01/2015 ...


Thanks!


WF 7.7.03, Win 7
 
Posts: 127 | Registered: January 12, 2017Report This Post
Expert
posted Hide Post
Here is an example using the very handy FPRINT function:

DEFINE FILE CAR
DATE1/YYMD = '2016/04/24';
END

TABLE FILE CAR
SUM
COMPUTE DATE1A/A10 = FPRINT(DATE1, 'MDYY', 'A10');
BY COUNTRY NOPRINT
ON TABLE HOLD AS HDATE1
END
-RUN

-READFILE HDATE1

DEFINE FILE CAR
TEXT1/A50 WITH MODEL = 'EFFECTIVE DATE OF CONTRACT: &DATE1A';
END


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
quote:
-SET &DATE1A = CHGDAT('YYMD','MDYY',&DATE1,'A10');

 
-SET &DATE1A = EDIT(CHGDAT('YYMD','MDYY',&DATE1,'A10'),'99/99/9999');
 


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
Platinum Member
posted Hide Post
Thank you Francis & Daniel - it works!!


WF 7.7.03, Win 7
 
Posts: 127 | Registered: January 12, 2017Report 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 issues with SQL passthru and -READ file statement

Copyright © 1996-2020 Information Builders