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     Date conversion [Resolved]

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Date conversion [Resolved]
 Login/Join
 
Platinum Member
posted
I have gotten a timestamp to convert to the following format:

1 Sep, 10

Now, I want to convert this to:

1-Sep-10

How can I do this? I couldn't find the answer in "The Book".

This message has been edited. Last edited by: Ted Michalski,


7.7.02
Windows
EXCEL, PDF, CSV, TEXT
 
Posts: 106 | Registered: June 25, 2009Report This Post
Platinum Member
posted Hide Post
Hi Ted,

Here's an example using the CAR file. Run this and see if this would work.

-*
DEFINE FILE CAR
CNT/I3 WITH COUNTRY = CNT + 1;
C_DT/A14 = DECODE CNT (
1 '20100322053005'
2 '20000326213005'
3 '20100330023005'
4 '20090402103005'
5 '20100407233005'
ELSE '???');
END
-*
TABLE FILE CAR
PRINT
CNT
C_DT
COUNTRY
WHERE RECORDLIMIT EQ 5
ON TABLE HOLD
END
-*
DEFINE FILE HOLD
C_DTS/HYYMDS = HINPUT(14, C_DT, 8, 'HYYMDS');
C_DTS_A/A9 = HCNVRT(C_DTS, '(HDMtY)', 9, 'A9');
C_DTS_B/A9 = CTRAN(9,C_DTS_A, 32, 45, 'A9');
C_DTS_C/A9 = IF EDIT(C_DTS_A,'9') EQ '0' THEN EDIT(CTRAN(9,C_DTS_A, 32, 45, 'A9'),'$99999999') ELSE CTRAN(9,C_DTS_A, 32, 45, 'A9');
END
-*
TABLE FILE HOLD
PRINT
CNT
C_DT
C_DTS
C_DTS_A
C_DTS_B
C_DTS_C
END

The field C_DTS_B keeps the leading zero on the day where C_DTS_C does not.

Jim


WebFocus 8.201M, Windows, App Studio
 
Posts: 227 | Location: Lincoln Nebraska | Registered: August 12, 2008Report This Post
Guru
posted Hide Post
What did you use to convert your date time to date formate? HDATE is not an option because I cant manipulate the date with it.


WebFOCUS 7.6.10
Windows
HTML
 
Posts: 294 | Registered: March 04, 2010Report This Post
Platinum Member
posted Hide Post
I used the following formula to convert the timestamp to this format:

1 Sep, 2010


VAL_DT_DISP/DMtY = HDATE(VAL_DT, 'DMtY');


7.7.02
Windows
EXCEL, PDF, CSV, TEXT
 
Posts: 106 | Registered: June 25, 2009Report This Post
<JG>
posted
quote:
/DMtY

Arif look at what was posted by jfr99
quote:
/HYYMDS

To use date functions, you must first convert to a valid internal date format.
 
Report This Post
Virtuoso
posted Hide Post
I think the only way you can get the format you want is to use EDIT with HCNVRT, as jfr99 suggested earlier. You can use a straight EDIT with a mask instead of the CTRAN function, but the result is the same.

C_DTS_C/A9 = IF EDIT(C_DTS_A,'9') EQ '0' THEN EDIT(C_DTS_A,'$9-999$-99') ELSE EDIT(C_DTS_A,'99-999$-99');


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Platinum Member
posted Hide Post
Thanks jfr99, but it looks like your inputs are in a different format than mine. Here's what I have:

2010-09-01 00:00:00

What I want is:

1-Sep-10


7.7.02
Windows
EXCEL, PDF, CSV, TEXT
 
Posts: 106 | Registered: June 25, 2009Report This Post
Expert
posted Hide Post
Then modify what jfr99 showed you to your data and adjust the code accordingly:

  
APP APPENDPATH IBISAMP
-RUN
DEFINE FILE CAR
CNT/I3 WITH COUNTRY = CNT + 1;
C_DT/A20 = DECODE CNT (
1 '20100322 05:30:05'
2 '20000326 21:30:05'
3 '20100330 02:30:05'
4 '20090402 10:30:05'
5 '20100407 23:30:05'
ELSE '???');
END
-*
TABLE FILE CAR
PRINT
CNT
C_DT
COUNTRY
WHERE RECORDLIMIT EQ 5
ON TABLE HOLD
END
-*
DEFINE FILE HOLD
C_DTS/HYYMDS = HINPUT(20, C_DT, 8, 'HYYMDS');
C_DTS_A/A9 = HCNVRT(C_DTS, '(HDMtY)', 9, 'A9');
C_DTS_B/A9 = CTRAN(9,C_DTS_A, 32, 45, 'A9');
C_DTS_C/A9 = IF EDIT(C_DTS_A,'9') EQ '0' THEN EDIT(CTRAN(9,C_DTS_A, 32, 45, 'A9'),'$99999999') ELSE 
                                                   CTRAN(9,C_DTS_A, 32, 45, 'A9');
END
-*
TABLE FILE HOLD
PRINT
CNT
C_DT
C_DTS
C_DTS_A
C_DTS_B
C_DTS_C
END
-EXIT


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1972 | Location: Centennial, CO | Registered: January 31, 2006Report This Post
Expert
posted Hide Post
-* File date56.fex

DT3 provides the date in the format you require, one digit day for dates before 10. 

DEFINE FILE CAR
DT1/HYYMDS = HINPUT(20, '2010-09-01 00:00:00', 8, 'HYYMDS');
END

TABLE FILE CAR
PRINT
DT1
COMPUTE DT2/DMY = HDATE(DT1, 'DMY');
COMPUTE DT3/A12 = DATETRAN(DT2,'(DMY)','(-dt)','EN',12,'A12');
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, 2005Report This Post
Platinum Member
posted Hide Post
Francis, thanks, this 'kind of' works. It does give me the desired format, but:

You have a hardcoded timestamp '2010-09-01 00:00:00' as an argument for the HINPUT function. When I put in my report variable(FLD_DT) in the formula:

DT1/HYYMDS = HINPUT(20, FLD_DATE, 8, 'HYYMDS');

It tells me that I have an erroneous argument.
When I put single quotes around my variable, it then gives me 31-Dec-00.

The timestamps I have in the database are:

2010-09-01 00:00:00
2010-09-02 00:00:00
.
.
.
.
2010-09-30 00:00:00

It looks like the formula is not picking up my variable.


7.7.02
Windows
EXCEL, PDF, CSV, TEXT
 
Posts: 106 | Registered: June 25, 2009Report This Post
Expert
posted Hide Post
The HINPUT in the DEFINE is to create a database date-time field, since none of the sample databases have one. You wouldn't need to do that step as you already have database date-time fields (not "variables").

You should only have to do the two COMPUTE statements - one to retrieve the Date portion of a Date-Time field, and the second to transform the Date field to an alpha string in the output format you desire.


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
Awesome, works like a charm. Thanks for your help!


7.7.02
Windows
EXCEL, PDF, CSV, TEXT
 
Posts: 106 | Registered: June 25, 2009Report 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     Date conversion [Resolved]

Copyright © 1996-2020 Information Builders