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     How to create a Date out of characters and strings

Read-Only Read-Only Topic
Go
Search
Notify
Tools
How to create a Date out of characters and strings
 Login/Join
 
<bigpgo>
posted
Hello. I'm trying to create a Date from 2 fields: one is YEAR (format A4), and the other is MM (format is I2). How could I create a Date of format YYM? I have an ugly solution, but I'm sure there is something better. Thank you.


COMPUTE myYear/D4 = ATODBL(YEAR, '4', myYear);
COMPUTE dummyDate/YY = '0000';
COMPUTE dummyDate2/YYMD = dummyDate;
COMPUTE myDate/YYMD = DATEADD(dummyDate2, 'Y', myYear);
COMPUTE myDate2/YYMD = DATEADD(myDate, 'M', MM-1);
COMPUTE myDate3/YYM = myDate2;
-* Finally, myDate3 is of the format that I need. Very ugly but it works.. Any suggestions?
 
Report This Post
Virtuoso
posted Hide Post
DEFINE FILE CAR
DATE1/A4 = '2005';
DATE2/M = '12';
DATE3/A4 = DATE1;
DATE4/A2 = EDIT(DATE2);

DATE5/A6 = DATE3| DATE4;
END
TABLE FILE CAR
PRINT CAR
DATE3 DATE4 DATE5
END
 
Posts: 1903 | Location: San Antonio | Registered: February 28, 2005Report This Post
<bigpgo>
posted
Thanks guys. TexasStingRay - your solution worked and it's compact, I'll go with that one.
 
Report This Post
Gold member
posted Hide Post
COMPUTE MonDayYearString/A6MDY = MON | DATE | YEAR;
COMPUTE MonDayYearDATE/MDY = MonDayYearString;
COMPUTE MonDayYearDATE1/MDYY = MonDayYearDATE;

I am getting 05/04/07, so when I tried to convert the date to mdyy format, its resulting in 05/04/1907. How can I get the date in 05/04/2007 format.

Thank you.
 
Posts: 59 | Registered: May 01, 2007Report This Post
Expert
posted Hide Post
KK,
You might want to investigate the DATECVT function
Your code is taking an alphabetic string and trying to force it into a whats called a 'smartdate' field, You need to understand the difference.
If all you want is an alphabetic character string that is '05/04/2007', then
COMPUTE MonDayYearString/A6MDY = MON | '/' | DATE |'/' |YEAR; will give you '05/04/07' if indded your year field is '07' and not '2007';
but if you want to sort by this field or do arithmetic with it, you can't, you need to convert it to whats called a smart date, with yymd or ymd or mdyy, etc, format




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report 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     How to create a Date out of characters and strings

Copyright © 1996-2020 Information Builders