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     [CLOSED] Finding month number from given week and year number

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] Finding month number from given week and year number
 Login/Join
 
Gold member
posted
Hello,

I came across a problem where I need to find the month number given a week and year number. Is there any function that can help me with this or will I have to burn a few more brain cells implementing some crazy algorythm? Smiler

Thanks in advance.

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


WebFOCUS App Studio 8103
Windows7
All outputs
 
Posts: 58 | Location: London, UK | Registered: May 09, 2011Report This Post
Virtuoso
posted Hide Post
Please give an example of what you are looking for. Not quite sure what you are asking.
 
Posts: 1903 | Location: San Antonio | Registered: February 28, 2005Report This Post
Virtuoso
posted Hide Post
Maybe this is something that could help you with your algorithm:
DEFINE FILE CAR
WEEK/I4 WITH COUNTRY = 12;
YEAR/YY WITH COUNTRY = 2004;
FDAY/DMYY = YEAR;
FWEEK/I2 = EDIT(EDIT(HYYWD(HDTTM(FDAY,8,'HYYMDIA'),'A10'),'$$$$$$99'));
FWEEK = IF FWEEK GT 1 THEN 0 ELSE 1;
DAYS = (WEEK - FWEEK) * 7;
HELP/DMYY = FDAY + DAYS;
NEWDATE/MYY = HELP;
END

TABLE FILE CAR
PRINT WEEK YEAR NEWDATE
END


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report This Post
Virtuoso
posted Hide Post
Similar to GamP's solution, but using different functions. First day of the year (JAN01) is converted to the number of days since WF base date (12/31/1900). Number of weeks is multiplied by 7 to obtain number of days. This number is added to the JAN01 base days (minus 1 because we start with the first day of the year). Finally, the total base days are converted back to a month SmartDate and then to a month number. Replace &DATEYY with your year and WEEK_NUMBER with your week number.

APP PREPENDPATH IBISAMP
-*
DEFINE FILE CAR
 JAN01/A8YYMD   WITH COUNTRY = '&DATEYY' | '0101';
 WEEK_NUMBER/I2 WITH COUNTRY = 11 ;
 YEAR_NUMBER/I6  = DATECVT(JAN01,'A8YYMD','I6');
 DAY_NUMBER/I3L  = (WEEK_NUMBER * 7) - 1 ;
 YEAR_DAY/I6     = YEAR_NUMBER + DAY_NUMBER ;
 YEAR_MONTH/M    = DATECVT(YEAR_DAY,'I6','M');
 MONTH_NUMBER/I2 = YEAR_MONTH ;
END
-*
TABLE FILE CAR
 PRINT
  YEAR_NUMBER
  DAY_NUMBER
  YEAR_DAY
  YEAR_MONTH
  MONTH_NUMBER
WHERE RECORDLIMIT EQ 1 ;
END

This message has been edited. Last edited by: Dan Satchell,


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Expert
posted Hide Post
Here's another method to determining the month:

-* File date_from_week.fex

DEFINE FILE CAR
DT_YEAR/I4 = 2009;
DT_WEEK/I2 = 24;

DT_1/A8YYMD = EDIT(DT_YEAR) || '0101';
DT_1H/HYYMD = HINPUT(8, DT_1, 8, 'HYYMDS');
DT_2H/HYYMD = HSETPT(DT_1H, 'WEEK', DT_WEEK, 8, DT_2H);

DT_MONTH/I2 = HPART(DT_2H, 'MONTH', DT_MONTH);
END

TABLE FILE CAR
PRINT
COUNTRY
DT_YEAR
DT_WEEK
DT_1H
DT_2H

DT_MONTH

WHERE RECORDLIMIT EQ 1
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
Virtuoso
posted Hide Post
quote:
HSETPT

I haven't used HSETPT before. Nice.


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Expert
posted Hide Post
Gotta use these crazy functions somewhere Smiler

It'll be fun to see how many solutions are suggested before diogopc responds.


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
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Finding month number from given week and year number

Copyright © 1996-2020 Information Builders