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     [SOLVED] Finding the week number for any given year.

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Finding the week number for any given year.
 Login/Join
 
Silver Member
posted
I have many transactions with a date time value and I want to determine within what week of the year that date time value falls. For example there are 52 weeks in a year and week 1 is 1/1/08 to 1/7/08 and week 2 is 1/8/08 to 1/14/08 and week 52 is 12/25/08 to 12/31/08 etc... I will then graph the results for the year; thus, I will have 52 plots on a graph which represents all my data for the full year of transactions. thanks for your time!

This message has been edited. Last edited by: Kerry,
 
Posts: 31 | Registered: November 17, 2005Report This Post
Platinum Member
posted Hide Post
DEFINE FILE CAR
DATE1/A10 WITH COUNTRY= TODAY(DATE);
DATE2/HMDYYs = HINPUT(14, DATE1, 8, 'HMDYYs');
WEEK/I2 = HPART(DATE2, 'WEEK', 'I2');
END
-*
TABLE FILE CAR
SUM
MAX.DATE1
MAX.DATE2
MAX.WEEK
END


WF 8 version 8.2.04. Windows.
In focus since 1990.
 
Posts: 189 | Location: pgh pa | Registered: October 06, 2004Report This Post
Expert
posted Hide Post
Unfortunately, this does not give the week number that Denny99 is looking for. The WEEK component of the Date-Time column is a Saturday-Friday week number (the range of which you can modify using the WEEKFIRST setting), while Denny99 is looking for a week number starting on the first day of the year, which may not be a Monday so there might be a discrepancy between the two.

2009:
 m  t  w  t  f  s  s  |  m  t  w  t  f  s  s
-- -- -- -- -- -- --  | -- -- -- -- -- -- --
          1  2  3  4  |  5  6  7  8  9 10 11
          0  0  1  1  |  1  1  1  1  1  2  2 <== week component of date-time field
          1  1  1  1  |  1  1  1  2  2  2  2 <== week number

I think you have to do this using the day-of-year component and divide by 7.

DEFINE FILE CAR
DATE1/A8 WITH COUNTRY= '20080108';
DATE2/HMDYYS = HINPUT(14, DATE1, 8, 'HMDYYS');
WEEK/I2 = HPART(DATE2, 'WEEK', 'I2');
DOY/I3 = HPART(DATE2, 'DAY-OF-YEAR', 'I3');
WEEKB/I2 = IF IMOD(DOY, 7, 'I3') EQ 0 THEN (DOY / 7) ELSE (DOY / 7) + 1;
END

TABLE FILE CAR
SUM
MAX.DATE1
MAX.DATE2
MAX.WEEK
MAX.DOY
MAX.WEEKB
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
Probably doesn't matter much, but the last day of the year is going to give you a 53rd plot point because a year is 52 weeks and 1 (or 2) days. Francis' code, for most purposes, solves the problem as it uses modular division but that still doesn't resolve the issue of the extra day(s).


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Report This Post
Expert
posted Hide Post
As the length of a year is virtually constant, give or take 1 second from year to year, the calc of weeks 1 to 52/53 is the best way.

All depends on what Denny99 wants in his graph.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Expert
posted Hide Post
... and don't forget that there are differences between week numbers depending upon what standard you need to use - MS or ISO 8601.

ISO 8601 begins numbering weeks for the first week to contain a Thursday (other factors as well but this is the main one) whereas MS (as usual) decide that week number one is the first whole week within a year.

Find out which convention that you are required to use and code accordingly.

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 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Virtuoso
posted Hide Post
Thinking of week numbers and things like that I would recommend this article.

The French Revolutionairy Calendar

It's a funny idea ....




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

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Expert
posted Hide Post
Sansculottides
Big Grin LOL
what a leap year tradition!
except the french seem to have it for 5 days instead of 1
say,,summit is about 5 days long...
hmmmm




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
Virtuoso
posted Hide Post
Yes

I tell my boss I go to Summit this afternoon and I will be back tomorrow......




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

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report 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     [SOLVED] Finding the week number for any given year.

Copyright © 1996-2020 Information Builders