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     Format DateTime as Date Character with "mm/dd/yyyy" format

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Format DateTime as Date Character with "mm/dd/yyyy" format
 Login/Join
 
Member
posted
OK, is it really this involved to simply change a date format to an alpha-10 with "mm/dd/yyyy" format?
I simply need to write a text string representation of my date to a file with the above format.

Here's my current solution to this:

Without changing the master and using SQL Server as the source I start with a date/time field of HYYMDs.
Example using a simple Define:

DEFINE FILE XYZ
FDATE/MDYY = HDATE(MY_BIRTHDAY,'MDYY'); -* First convert date to mm/dd/yyy as date
ALPHA_DATE/A8=DATECVT(ADATE,'MDYY','A8MDYY'); -* Next convert to alpha 8 as mmddyyyy
ALPHA_DATE_FMT/A10 = EDIT(ALPHA_DATE,'99/99/9999'); -* Finally convert to alpha 10 using edit with mask
END

TABLE FILE XYZ
PRINT
MY_BIRTHDAY/HYYMDs 'UNTOUCHED'
FDATE/MDYY AS 'DATE_MM/DD/YYYY'
ALPHA_DATE/A8 AS 'ALPHA8'
ALPHA_DATE_FMT/A10 AS 'ALPHA10_MM/DD/YYYY'
END

So I get: (fields are stacked for viewing)
MY_BIRTHDAY
05/15/1974:00:00:00.000

DATE_MM/DD/YYYY
05/15/1974

ALPHA8
05151974

ALPHA10_MM/DD/YYYY
05/15/1974

Surely there's a better/quicker way to arrive at a text string date with "mm/dd/yyyy" format. Right?

This message has been edited. Last edited by: Phil DeBusk,


WebFOCUS 7.6
Windows, All Outputs
 
Posts: 14 | Registered: November 08, 2011Report This Post
Expert
posted Hide Post
Try this - two steps:
COMPUTE DT1A/A8MDYY = HDATE(MY_BIRTHDAY, 'MDYY');
COMPUTE DT1B/A10 = EDIT(DT1A,'99/99/9999');


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
Phil - You might want to look at the (almost) 1001 Ways to Work with Dates covering thru release 8.0.2 from Aviter, Inc.....nearly everything that you will ever need to know to manipulate dates is there.

Vivian

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


Vivian Perlmutter
Aviter, Inc.


WebFOCUS Keysheet Rel. 8.0.2
(Almost) 1001 Ways to Work with Dates thru Rel. 8.0.2
Focus since 1982
WebFOCUS since the beginning
Vivian@aviter.com

 
Posts: 191 | Location: Henderson, Nevada | Registered: April 29, 2003Report This Post
Virtuoso
posted Hide Post
There are so many different ways of manipulating dates, the 1001 way to work with dates has the answer and would have saved time and effort.

ALPHA_DATE_FMT/A10=HCNVRT(MY_BIRTHDAY,'(HMDYY)',20,'A10');


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Silver Member
posted Hide Post
I'd use EDIT if you can:

http://geekswithblogs.net/BI4f...date-conversion.aspx


WebFOCUS 8.0.0.8, Windows 7
 
Posts: 36 | Location: Portland, OR (USA) | Registered: October 11, 2012Report This Post
Virtuoso
posted Hide Post
quote:
I'd use EDIT if you can

Other than using EDIT within the techniques that Phil and Francis have already come up with, how would EDIT help?


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Platinum Member
posted Hide Post
Phil, to convert a Date format field into an ALPHA with component demarcations in one step, use FPRINT. Note that FPRINT will also do a conversion from YYMD to MDYY.

TABLE FILE CAR
PRINT CAR 
COMPUTE CURRENT_HMDYY/HYYMDs  = HGETC(8,'HYYMDs');
COMPUTE CURRENT_ALPHA/A10    = FPRINT(CURRENT_HMDYY,'HMDYY','A10');
END


Check it by adding "ON TABLE SAVE" and reviewing the output. Then,look at the save.ftm and you'll see that CURRENT_ALPHA is indeed stored in ALPHA format with the component slashes.

Lastly, I do have an old version of the book but, FPRINT isn't covered. I don't know if it's covered in the latest version ... hmmm ... maybe I should write a book titled "(Just About) a Thousand different ways to use FPRINT"!

(just kidding folks)

For more FPRINT, check this out:
Converting To Alpha - Topic

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



In FOCUS since 1985 - WF 8.009/8.104 Win 8 Outputs: ALL of 'em! Adapters: Sql Server Teradata Oracle
 
Posts: 161 | Location: Dallas, TX | Registered: February 20, 2009Report This Post
Silver Member
posted Hide Post
FPRINT function was added to WebFocus in release 7.7.01. The newest version of the "Dates" book does include FPRINT.
It is not in the current version of the dates book, but thanks to a hint from Francis Mariani, I have added it to the next release (around Oct 2013).
a) REFSDATE/MDYY WITH SD_MDY1='04152006';             
b) REFHMDYY/HMDYYS WITH SD_MDY1 = HGETC(8,REFHMDYY) ; 
c) REFLDATE/A8MDYY WITH SD_MDY1 = '04152006 ;         
d) REF_S01/A10 = FPRINT(REFSDATE,'M.D.YY', 'A10');    
e) REF_S02/A16 = FPRINT(REFSDATE,'MtrDYY', 'A16');    
f) REF_S03/A24 = FPRINT(REFSDATE,'MtrDwrYY', 'A24');  
g) REF_S04/A30 = FPRINT(REFHMDYY,'HMDYYS', 'A30');    
h) REF_S05/A30 = FPRINT(REFHMDYY,'HYYMDS', 'A30');    
i) REF_S06/A30 = FPRINT(REFHMDYY,'HYYMTdS', 'A30');   
j) REF_S07/A30 = FPRINT(REFHMDYY,'HYYMTDs', 'A30');   
k) REF_S08/A16 = FPRINT(REFLDATE,'A8MTDYY', 'A16');   
l) REF_S09/A16 = FPRINT(REFLDATE,'A8MtDYY', 'A16');   
Results
(a)  Base Smart Date =  04/15/2006                  
(b)    Base DateTime =  06/03/2013 19:46:21         
(c) Legacy Base Date =  04/15/2006                  
                         1    1    2    2    3     
out-format    ....5....0....5....0....5....0   
(d)   M.D.YY =  04.15.2006                         
(e)   MtrDYY =  April 15, 2006                     
(f) MtrDwrYY =  April 15 2006, Saturday            
(g)   HMDYYS =  06/03/2013 19:46:21                
(h)   HYYMDS =  2013/06/03 19:46:21                
(i)  HYYMTdS =  2013 June  3 19:46:21              
(j)  HYYMTDs =  2013 June 03 19:46:21.299          
(k)    MTDYY =  APR 15 2006                        
(l)    MtDYY =  APR 15 2006     
  



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, 2013Report This Post
Platinum Member
posted Hide Post
That's good news John. Thanks! The book is truly useful. I have the first printing of the 2nd edition, dated 2006 so, it's probably time to get the "newest" version when it comes out in October.

BTW, FPRINT was added to official cannon in 7.7.01 but was added to 7.6.x as an undocumented feature...not sure which version it was added to but it works in our 7.6.11 environment.



In FOCUS since 1985 - WF 8.009/8.104 Win 8 Outputs: ALL of 'em! Adapters: Sql Server Teradata Oracle
 
Posts: 161 | Location: Dallas, TX | Registered: February 20, 2009Report This Post
Silver Member
posted Hide Post
Thanks for the feedback. I will update the Keysheet and the dates books to reflect this. For now I'll just call it 7.6.11.



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, 2013Report 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     Format DateTime as Date Character with "mm/dd/yyyy" format

Copyright © 1996-2020 Information Builders