Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] How to convert the date format to String
Go
New
Search
Notify
Tools
Reply
  
[SOLVED] How to convert the date format to String
 Login/Join
 
Gold member
posted
Hi All,

I am having below requirement.

In one of my table,one of my column is having date format like 'May 30, 2013'.

I need to add 6 months to this date after that i need to append the string to this column. I am trying like below.

COMPUTE FREQUENCYDATA2/MDtrYY =DATEADD('May 30, 2013', 'M', -6);

After this how to append the String to "FREQUENCYDATA2" variable?

Can anyone help me out of this.

Thanks in advance.

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


Web FOCUS 7.7.03
PDF
 
Posts: 69 | Registered: May 24, 2013Reply With QuoteReport This Post
Virtuoso
posted Hide Post
In this case you need a book...

There is so much to do about dates that you should buy "almost 1001 ... Titlebook

It is worth the price




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Reply With QuoteReport This Post
Gold member
posted Hide Post
Thankyou for your suggestion.

I will go through that book but i dont have enough time to read the book.

Can you please provide me some code to append the data to date value?


Web FOCUS 7.7.03
PDF
 
Posts: 69 | Registered: May 24, 2013Reply With QuoteReport This Post
Expert
posted Hide Post
Santu,

Please try out the search function above to help you out.

As you are new to WebFOCUS it is likely that most of the questions you have may well have been asked before - and will have been answered also.

Also check out your local branch to see what training is available to you.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.06 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5601 | Location: United Kingdom | Registered: April 08, 2004Reply With QuoteReport This Post
Silver Member
posted Hide Post
You can use the DATETRAN function to convert the date to a string and then use concatenation to append the text that you want to it.

REF_S10/A22 = DATETRAN(FREQUENCYDATA2,'(MDYY)','(tr)' ,'EN',22,REF_S10);

will produce a string representation of your computed date - concatenate to it as needed.

This message has been edited. Last edited by: John W Price,



WebFOCUS 8.0.2, FOCUS since 1977 - John@Aviter.com
PDF , Excel, FOCUS, Author of the Keysheets and Dates book.
www.Aviter.com
 
Posts: 40 | Registered: April 19, 2013Reply With QuoteReport This Post
Expert
posted Hide Post
You can also use the FPRINT function, much easier than the DATETRAN function:

DEFINE FILE CAR
MYDATE/YYMD WITH COUNTRY = '&YYMD';
END

TABLE FILE CAR
PRINT
COMPUTE DT1/A10 = FPRINT(MYDATE,'YYMD', 'A10');
COMPUTE DT3/A10 = FPRINT(MYDATE,'D.M.YY', 'A10');
COMPUTE DT4/A10 = FPRINT(MYDATE,'M-D-YY', 'A10');

COMPUTE DT5/A20 = FPRINT(MYDATE,'DMtYY', 'A20');
COMPUTE DT2/A20 = FPRINT(MYDATE,'MtrDYY', 'A20');
COMPUTE DT6/A20 = FPRINT(MYDATE,'DMTRYY', 'A20');
COMPUTE DT7/A20 = FPRINT(MYDATE,'wrMtrDYY', 'A20');
COMPUTE DT8/A20 = FPRINT(MYDATE,'WMTDYY', 'A20');

BY COUNTRY
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, 2005Reply With QuoteReport This Post
Expert
posted Hide Post
John, Vivian, does the Key Sheet show how to use the FPRINT function with date columns?


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, 2005Reply With QuoteReport This Post
Silver Member
posted Hide Post
Francis,
No it does not. It shows the input as numeric format. This would work with "legacy dates" but not "Smart Dates" or "Date Time" (WebFOCUS).
Looks like I'll have to set up some tests to see what can be done with those data types. Thanks for the heads up.
Just checked the FOCUS Keysheet and it indicates any input field. The Dates book does not reference FPRINT at all - looks like I have a lot of work to do.

This message has been edited. Last edited by: John W Price,



WebFOCUS 8.0.2, FOCUS since 1977 - John@Aviter.com
PDF , Excel, FOCUS, Author of the Keysheets and Dates book.
www.Aviter.com
 
Posts: 40 | Registered: April 19, 2013Reply With QuoteReport This Post
Expert
posted Hide Post
John,

Thanks for looking into this. The IBI documentation on FPRINT is meagre.

Cheers,


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, 2005Reply With QuoteReport This Post
Gold member
posted Hide Post
Francis:

I, too, like the new FPRINT! Still need DATETRAN sometimes to get rid of those pesky commas. Add these lines and compare DT12 to DT13:

COMPUTE TEMP/YYM=MYDATE;
COMPUTE DT12/A20=FPRINT(TEMP,'MtYY','A20');
COMPUTE D13/A20=DATETRAN(TEMP,'(MYY)','(t)','EN',8,'A8');


Craig


v8.1.04, 64-bit Windows (Reporting Server), Apache Tomcat (Web/App Server), HTML, PDF, AHTML, Excel outputs
 
Posts: 57 | Location: Des Moines, IA | Registered: April 30, 2009Reply With QuoteReport This Post
Expert
posted Hide Post
Craig, thanks for pointing that out. Here's another way to eliminate the pesky comma:
COMPUTE DT11/A9 = EDIT(FPRINT(TEMP,'MtYY','A9'),'999$99999');


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, 2005Reply With QuoteReport This Post
Gold member
posted Hide Post
Francis:

Now I like that A LOT better than DATETRAN! Scares me that the straightforward sometimes escapes me!

Thanks...

Craig


v8.1.04, 64-bit Windows (Reporting Server), Apache Tomcat (Web/App Server), HTML, PDF, AHTML, Excel outputs
 
Posts: 57 | Location: Des Moines, IA | Registered: April 30, 2009Reply With QuoteReport This Post
Gold member
posted Hide Post
Hi all,

Problem got solved.

As Francis Mariani said its got resolved.

Thanks to everyone.....


Web FOCUS 7.7.03
PDF
 
Posts: 69 | Registered: May 24, 2013Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] How to convert the date format to String

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.