Focal Point
[SOLVED] How to convert the date format to String

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

June 01, 2013, 04:08 AM
santu
[SOLVED] How to convert the date format to String
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
June 01, 2013, 08:12 AM
FrankDutch
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

June 01, 2013, 08:17 AM
santu
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
June 01, 2013, 12:48 PM
Tony A
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.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
June 02, 2013, 06:55 AM
John W Price
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
June 03, 2013, 10:11 AM
Francis Mariani
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
June 03, 2013, 10:13 AM
Francis Mariani
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
June 03, 2013, 08:36 PM
John W Price
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
June 04, 2013, 09:21 AM
Francis Mariani
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
June 04, 2013, 10:30 AM
Craig R.
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
June 04, 2013, 10:48 AM
Francis Mariani
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
June 04, 2013, 11:48 AM
Craig R.
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
June 04, 2013, 01:39 PM
santu
Hi all,

Problem got solved.

As Francis Mariani said its got resolved.

Thanks to everyone.....


Web FOCUS 7.7.03
PDF