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] How do I set &WEEKID to match our week (Sunday - Saturday)?

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] How do I set &WEEKID to match our week (Sunday - Saturday)?
 Login/Join
 
Member
posted
How do I set &WEEKID to match our week (Sunday - Saturday)? From the system date, the following returns last week's WEEKID of 200918. It seems to be reflecting Saturday - Friday. I've tried to SET WEEKFIRST to everything from 0 to 7, with no change to the output. I need to pass &WEEKID to my WHERE statements as 200919 (YYYYWW). WEEKID 200919 = 05/03/2009 - 05/09/2009 (Sunday - Saturday). If there's a better way to SET &WEEKID, please let me know.

-SET &TODAY = &YYMD;
-SET &YEAR = EDIT(&TODAY,'9999$$$$');
-SET WEEKFIRST = 5; -*I also tried SET WEEKFIRST = {5|7}
-SET &CURR_WEEK = EDIT(HPART(HDTTM(DATECVT (&TODAY, 'I8YYMD', 'YYMD'), 8, 'HYYMDIA'), WEEK, 'I2'),'99');
-SET &WEEKID = EDIT(&YEAR||&CURR_WEEK,'999999');
-TYPE TODAY = &TODAY
-TYPE YEAR = &YEAR
-TYPE CURR_WEEK = &CURR_WEEK
-TYPE &WEEKID = &WEEKID
-EXIT

Result:
TODAY = 20090507
YEAR = 2009
CURR_WEEK = 18 (s/b 19)
CURR_WKID = 200918 (s/b 200919)

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


WebFOCUS 7.6.11, Windows XP, Excel, HTML, PDF
 
Posts: 25 | Location: Salt Lake City | Registered: June 03, 2008Report This Post
Virtuoso
posted Hide Post
did you do a search in this forum

the definition of the weeknumber is always a discussion.
It depends on the first thursday of the year. and there is also a discussion if a week should start on Sunday or Monday.
But what you can do is just add 1 to the result you get.




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
<JG>
posted
Error number 1

quote:

-SET WEEKFIRST = 5;


It should be

SET WEEKFIRST = 1
-RUN

It's not a DM variable it's a standard SET command and the -RUN is required to execute the stack
before any further processing.

quote:
Syntax: How to Set a Day as the Start of the Week
SET WEEKFIRST = {value|7}
where:

value
Can be:

1 through 7, representing Sunday through Saturday with non-standard week numbering.

or

ISO1 through ISO7, representing Sunday through Saturday with ISO standard week numbering. Note: ISO is a synonym for ISO2.

The ISO standard establishes Monday as the first day of the week, so to be fully ISO compliant, the WEEKFIRST parameter should be set to ISO or ISO2.


Try This

SET WEEKFIRST = ISO2
-RUN
-SET &YYWD=HYYWD((HDTTM((DATECVT (&YYMD, 'I8YYMD', 'YYMD')),8, 'HYYMDS')), 'A10');
-SET &YEAR = EDIT(&YYWD,'9999$$$$');
-SET &WEEK = EDIT(&YYWD,'$$$$$$99');

-TYPE &YYWD
-TYPE &YEAR
-TYPE &WEEK
 
Report This Post
Member
posted Hide Post
JG,
From your suggestion, I get the following errors.
(FOC210) THE DATA VALUE HAS A FORMAT ERROR: ISO2 (no error with 1 - 7, but has no effect on the result)
(FOC263) EXTERNAL FUNCTION OR LOAD MODULE NOT FOUND: HYYWD

Frank,
Your suggestion to add 1 to the result, will not work if today is 12/31/2008. The final result would be 200853 (200852 +1), instead of 200901. Also -SET WEEKFIRST = 5 (w/RUN), has no effect on the result.

Result:
TODAY = 20081231
YEAR = 2008
CURR_WEEK = 52
CURR_WKID = 200852
ADJ_WKID = 200853

I also tried using -SET &CURR_WKEND = DATEMOV(&TODAY,'EOW'). But for the same date of 12/31/2008, I get 20081233 for end of week. The result for &CURR_WKEND should be 20090102. If I could get this to work, I could add 1 day for Sat 20090103, like DATEMOV(&TODAY,'EOW')+1. The result of Saturday always gives me the correct week id. Unfortunately, these reports need to be run Monday - Friday.


WebFOCUS 7.6.11, Windows XP, Excel, HTML, PDF
 
Posts: 25 | Location: Salt Lake City | Registered: June 03, 2008Report This Post
Expert
posted Hide Post
quote:
-SET WEEKFIRST = 5

take the dash out of -SET, as jg says.




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
Expert
posted Hide Post
This fex illustrates how to determine the week number for several dates in a row. It uses a DEFINE on the CAR file. It is sometimes difficult to use Date-time functions in Dialogue Manager, I think that is why the week number in your EDIT of HPART does not give the correct result.

SET WEEKFIRST = 1

DEFINE FILE CAR
HDT1/HYYMD = DT(20090501 0:00:00);
HDT2/HYYMD = DT(20090502 0:00:00);
HDT3/HYYMD = DT(20090503 0:00:00);
HDT4/HYYMD = DT(20090504 0:00:00);
HDT5/HYYMD = DT(20090505 0:00:00);
HDT6/HYYMD = DT(20090506 0:00:00);
HDT7/HYYMD = DT(20090507 0:00:00);
HDT8/HYYMD = DT(20090508 0:00:00);
HDT9/HYYMD = DT(20090509 0:00:00);
HDTA/HYYMD = DT(20090510 0:00:00);
HDTB/HYYMD = DT(20090511 0:00:00);
HDTC/HYYMD = DT(20090512 0:00:00);

DW1/I2 = HPART(HDT1, 'WEEKDAY', 'I2');
DW2/I2 = HPART(HDT2, 'WEEKDAY', 'I2');
DW3/I2 = HPART(HDT3, 'WEEKDAY', 'I2');
DW4/I2 = HPART(HDT4, 'WEEKDAY', 'I2');
DW5/I2 = HPART(HDT5, 'WEEKDAY', 'I2');
DW6/I2 = HPART(HDT6, 'WEEKDAY', 'I2');
DW7/I2 = HPART(HDT7, 'WEEKDAY', 'I2');
DW8/I2 = HPART(HDT8, 'WEEKDAY', 'I2');
DW9/I2 = HPART(HDT9, 'WEEKDAY', 'I2');
DWA/I2 = HPART(HDTA, 'WEEKDAY', 'I2');
DWB/I2 = HPART(HDTB, 'WEEKDAY', 'I2');
DWC/I2 = HPART(HDTC, 'WEEKDAY', 'I2');

W1/I2 = HPART(HDT1, 'WEEK', 'I2');
W2/I2 = HPART(HDT2, 'WEEK', 'I2');
W3/I2 = HPART(HDT3, 'WEEK', 'I2');
W4/I2 = HPART(HDT4, 'WEEK', 'I2');
W5/I2 = HPART(HDT5, 'WEEK', 'I2');
W6/I2 = HPART(HDT6, 'WEEK', 'I2');
W7/I2 = HPART(HDT7, 'WEEK', 'I2');
W8/I2 = HPART(HDT8, 'WEEK', 'I2');
W9/I2 = HPART(HDT9, 'WEEK', 'I2');
WA/I2 = HPART(HDTA, 'WEEK', 'I2');
WB/I2 = HPART(HDTB, 'WEEK', 'I2');
WC/I2 = HPART(HDTC, 'WEEK', 'I2');
END

TABLE FILE CAR
PRINT
COUNTRY NOPRINT
HDT1 DW1 W1 OVER
HDT2 DW2 W2 OVER
HDT3 DW3 W3 OVER
HDT4 DW4 W4 OVER
HDT5 DW5 W5 OVER
HDT6 DW6 W6 OVER
HDT7 DW7 W7 OVER
HDT8 DW8 W8 OVER
HDT9 DW9 W9 OVER
HDTA DWA WA OVER
HDTB DWB WB OVER
HDTC DWC WC
WHERE RECORDLIMIT EQ 1
END


Result:

HDT1 2009/05/01 DW1 6 W1 17 
HDT2 2009/05/02 DW2 7 W2 17 
HDT3 2009/05/03 DW3 1 W3 18 
HDT4 2009/05/04 DW4 2 W4 18 
HDT5 2009/05/05 DW5 3 W5 18 
HDT6 2009/05/06 DW6 4 W6 18 
HDT7 2009/05/07 DW7 5 W7 18 
HDT8 2009/05/08 DW8 6 W8 18 
HDT9 2009/05/09 DW9 7 W9 18 
HDTA 2009/05/10 DWA 1 WA 19 
HDTB 2009/05/11 DWB 2 WB 19 
HDTC 2009/05/12 DWC 3 WC 19 


How to use this to determine the week number for the current date:

SET HOLDLIST   = PRINTONLY
SET HOLDFORMAT = ALPHA
SET WEEKFIRST  = 1

TABLE FILE CAR
PRINT
COUNTRY NOPRINT
COMPUTE HDT1/HYYMD = DT(&YYMD 0:00:00); NOPRINT
COMPUTE W1/I2      = HPART(HDT1, 'WEEK', 'I2');
WHERE RECORDLIMIT EQ 1
ON TABLE 
ON TABLE HOLD AS H001
END
-RUN

-READ H001 &CURR_WEEK.I2.

-SET &CURR_YY   = EDIT(&YYMD,'9999$$$$');
-SET &CURR_WKID = &CURR_YY | &CURR_WEEK

-TYPE TODAY = &YYMD
-TYPE YEAR = &CURR_YY
-TYPE CURR_WEEK = &CURR_WEEK
-TYPE CURR_WKID = &CURR_WKID



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
AFS-Skier,
quote:
From your suggestion, I get the following errors.
(FOC210) THE DATA VALUE HAS A FORMAT ERROR: ISO2 (no error with 1 - 7, but has no effect on the result)
(FOC263) EXTERNAL FUNCTION OR LOAD MODULE NOT FOUND: HYYWD

Although you specified in your profile that you're using 765 webfocus, these messages indicate that it is run in a lower release, probably a 71x version.
These settings and routines are available as of webfocus 761 and they give the desired results in all 76x versions.


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report This Post
Member
posted Hide Post
GamP,

You're right, I'm running 765. But our server is 716. Our admin is updating to 769 when the it's released this week.

Thanks, Kevin


WebFOCUS 7.6.11, Windows XP, Excel, HTML, PDF
 
Posts: 25 | Location: Salt Lake City | Registered: June 03, 2008Report 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] How do I set &WEEKID to match our week (Sunday - Saturday)?

Copyright © 1996-2020 Information Builders