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] DTPART Issue?

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] DTPART Issue?
 Login/Join
 
Expert
posted
Here's a special thanks to BabakNYC, David Briars, J.Gross, and Hallway for their great input.

I'm seeing an issue with the DTPART function in 8204. Is anyone else seeing such symptoms?

Here's my pseudo-code:
TABLE FILE DATE_TO_CHECK
"DTPART Check for Week in Date"
SUM 
COMPUTE YEAR/I4 = DTPART(DATE_TO_CHECK, YEAR) ;
COMPUTE WEEK/I2 = DTPART(DATE_TO_CHECK, WEEK) ;
BY DATE_TO_CHECK AS 'Date To Check'
WHERE DATE_TO_CHECK FROM '20171221' TO '20180131'
ON TABLE PCHOLD FORMAT XLSX
END

and, here's my results: Why is January 1 2018 in Week 53?
DTPART Check for Week in Date
Date To Check	YEAR	WEEK
2017/12/21	2017	51
2017/12/23	2017	51
2017/12/24	2017	52
2017/12/30	2017	52
2018/01/01	2018	53 <---
2018/01/05	2018	53 <--- 
2018/01/07	2018	1
2018/01/13	2018	1
2018/01/14	2018	2
2018/01/20	2018	2
2018/01/21	2018	3
2018/01/27	2018	3
2018/01/28	2018	4
2018/01/29	2018	4

Any suggestions on how to alleviate this are graciously welcomed.
Thank You, Doug

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




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Expert
posted Hide Post
Sorry... I often ask "Can you do that with the CAR file?". So, here it is:
TABLE FILE CAR
"DTPART Test"
SUM DCOST NOPRINT
COMPUTE 20171228/I2 = DTPART('20171228', WEEK) ; COMPUTE Day/I2 = DTPART('20171228', WEEKDAY) ; OVER
COMPUTE 20171229/I2 = DTPART('20171229', WEEK) ; COMPUTE Day/I2 = DTPART('20171229', WEEKDAY) ; OVER
COMPUTE 20171230/I2 = DTPART('20171230', WEEK) ; COMPUTE Day/I2 = DTPART('20171230', WEEKDAY) ; OVER
COMPUTE 20171231/I2 = DTPART('20171231', WEEK) ; COMPUTE Day/I2 = DTPART('20171231', WEEKDAY) ; OVER
COMPUTE 20180101/I2 = DTPART('20180101', WEEK) ; COMPUTE Day/I2 = DTPART('20180101', WEEKDAY) ; OVER
COMPUTE 20180102/I2 = DTPART('20180102', WEEK) ; COMPUTE Day/I2 = DTPART('20180102', WEEKDAY) ; OVER
COMPUTE 20180103/I2 = DTPART('20180103', WEEK) ; COMPUTE Day/I2 = DTPART('20180103', WEEKDAY) ; OVER
COMPUTE 20180104/I2 = DTPART('20180104', WEEK) ; COMPUTE Day/I2 = DTPART('20180104', WEEKDAY) ; OVER
COMPUTE 20180105/I2 = DTPART('20180105', WEEK) ; COMPUTE Day/I2 = DTPART('20180105', WEEKDAY) ; OVER
COMPUTE 20180106/I2 = DTPART('20180106', WEEK) ; COMPUTE Day/I2 = DTPART('20180106', WEEKDAY) ; OVER
COMPUTE 20180107/I2 = DTPART('20180107', WEEK) ; COMPUTE Day/I2 = DTPART('20180107', WEEKDAY) ; OVER
COMPUTE 20180108/I2 = DTPART('20180108', WEEK) ; COMPUTE Day/I2 = DTPART('20180108', WEEKDAY) ;
BY COUNTRY NOPRINT
WHERE RECORDLIMIT EQ 1
END
With these results (The "<--" were added for clarity):

DTPART Test 
 
20171228 52 Day 5 
20171229 52 Day 6 
20171230 52 Day 7 
20171231 53 Day 1 
20180101 53 Day 2 <--
20180102 53 Day 3 <--
20180103 53 Day 4 <--
20180104 53 Day 5 <--
20180105 53 Day 6 <--
20180106 53 Day 7 <--
20180107 1 Day 1 
20180108 1 Day 2 
It looks like Week 53 is a carry-over from 2017. Should that be?

This message has been edited. Last edited by: Doug,
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Virtuoso
posted Hide Post
Doug: I looked this concept up and found an article that basically says:

"While it only happens every five or six years, a 53-week broadcast year isn’t unheard of. These happen around a leap year or when January 1 falls on a Saturday or Sunday. That means 2017 is a 53-week year, which hasn’t happened since 2012. In 2017, 4th quarter will have 14 weeks with October and December each being 5 weeks long. Additional years where there will be 53 weeks include 2023, 2028 and 2034."


WebFOCUS 8206, Unix, Windows
 
Posts: 1853 | Location: New York City | Registered: December 30, 2015Report This Post
Master
posted Hide Post
Can you do a '? SET WEEKFIRST' to see the value of WEEKFIRST at your site?
   
SET WEEKFIRST = 2
-RUN
DEFINE FILE CAR
 DATE_TO_CHECK/HYYMD = DT(20180101);
 WEEK/I2 = DTPART(DATE_TO_CHECK, WEEK) ;
END
TABLE FILE CAR
PRINT CAR DATE_TO_CHECK WEEK
IF RECORDLIMIT EQ 1
END
-EXIT


Shows me week 1, and

SET WEEKFIRST = 1
-RUN
DEFINE FILE CAR
 DATE_TO_CHECK/HYYMD = DT(20180101);
 WEEK/I2 = DTPART(DATE_TO_CHECK, WEEK) ;
END
TABLE FILE CAR
PRINT CAR DATE_TO_CHECK WEEK
IF RECORDLIMIT EQ 1
END
-EXIT  

Shows week 53.




Pilot: WebFOCUS 8.2.06 Test: WebFOCUS 8.1.05M Prod: WebFOCUS 8.1.05M Server: Windows Server 2016/Tomcat Standalone Workstation: Windows 10/IE11+Edge Database: Oracle 12c, Netezza, & MS SQL Server 2019 Output: AHTML/XLSX/HTML/PDF/JSCHART Tools: WFDS, Repository Content, BI Portal Designer & ReportCaster
 
Posts: 822 | Registered: April 23, 2003Report This Post
Expert
posted Hide Post
Thanks, I understand that there are "53 week years". But, is the week always complete weeks, based on the first day of the week? And, if so, it can be different based on what the first day of the week is, right?

Here's the underlying issue: I'm converting reports from Tableau to WebFOCUS based on week. WebFOCUS is showing the weeks being one week behind that shown in the Tableau reports. BTW: Outlook even says we're currently in week 44, while WebFOCUS says we're in week 43. I'm checking with my Tableau team on this as well.
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Virtuoso
posted Hide Post
I haven't done much with this. I'd say this is worth a conversation with IB Tech support. If Outlook is saying something different from what WebFOCUS generates then I'd love to know IB's explanation.


WebFOCUS 8206, Unix, Windows
 
Posts: 1853 | Location: New York City | Registered: December 30, 2015Report This Post
Expert
posted Hide Post
Excellent point David! ? SET WEEKFIRST
It shows as "WEEKFIRST 0"
However, I ran that same report with the following code prepended to it, and got the same results.
? SET WEEKFIRST
-RUN
SET WEEKFIRST = 1
-RUN
? SET WEEKFIRST
-EXIT
The final result of the "? SET WEEKFIRST" shows it as 1. Could it be a DTPART routine issue not recognizing the setting of weekfirst?
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Expert
posted Hide Post
quote:
I'd love to know IB's explanation.
Good One BabakNYC ... Me too ... Even with the SET WEEKFIRST ...

It's time for a case.
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Expert
posted Hide Post
Can anyone get anything else from the code in my posted Wed Oct 31 2018 12:35 post, especially using 8204?




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Virtuoso
posted Hide Post
The Keysheet lists the options for
SET WEEKFIRST=option
as
option: 1 to 7 (Sunday to Saturday)
option: ISO2

Have you tried the ISO2 option?

-Jack
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Master
posted Hide Post
quote:
Originally posted by Doug:
Can anyone get anything else from the code in my posted Wed Oct 31 2018 12:35 post, especially using 8204?


Try this:
  
SET WEEKFIRST = ISO1

TABLE FILE CAR
"DTPART Test"
SUM DCOST NOPRINT
COMPUTE 20171228/I2 = DTPART('20171228', WEEK) ; COMPUTE Day/I2 = DTPART('20171228', WEEKDAY) ; OVER
COMPUTE 20171229/I2 = DTPART('20171229', WEEK) ; COMPUTE Day/I2 = DTPART('20171229', WEEKDAY) ; OVER
COMPUTE 20171230/I2 = DTPART('20171230', WEEK) ; COMPUTE Day/I2 = DTPART('20171230', WEEKDAY) ; OVER
COMPUTE 20171231/I2 = DTPART('20171231', WEEK) ; COMPUTE Day/I2 = DTPART('20171231', WEEKDAY) ; OVER
COMPUTE 20180101/I2 = DTPART('20180101', WEEK) ; COMPUTE Day/I2 = DTPART('20180101', WEEKDAY) ; OVER
COMPUTE 20180102/I2 = DTPART('20180102', WEEK) ; COMPUTE Day/I2 = DTPART('20180102', WEEKDAY) ; OVER
COMPUTE 20180103/I2 = DTPART('20180103', WEEK) ; COMPUTE Day/I2 = DTPART('20180103', WEEKDAY) ; OVER
COMPUTE 20180104/I2 = DTPART('20180104', WEEK) ; COMPUTE Day/I2 = DTPART('20180104', WEEKDAY) ; OVER
COMPUTE 20180105/I2 = DTPART('20180105', WEEK) ; COMPUTE Day/I2 = DTPART('20180105', WEEKDAY) ; OVER
COMPUTE 20180106/I2 = DTPART('20180106', WEEK) ; COMPUTE Day/I2 = DTPART('20180106', WEEKDAY) ; OVER
COMPUTE 20180107/I2 = DTPART('20180107', WEEK) ; COMPUTE Day/I2 = DTPART('20180107', WEEKDAY) ; OVER
COMPUTE 20180108/I2 = DTPART('20180108', WEEK) ; COMPUTE Day/I2 = DTPART('20180108', WEEKDAY) ;
BY COUNTRY NOPRINT
WHERE RECORDLIMIT EQ 1
END


Below is a query to see all the available values of WEEKFIRST:
TABLE FILE sysset
BY SETNAME
BY SETDESC
BY SERVDESC
BY SETVALTYPE
BY SETMAXLEN AS 'Max,Length/,Value'
BY SETFPROMPT AS 'Set,From,PROMPT'
BY SETFTAB AS 'Set,From,TABLE'
BY SETFPARMS AS 'Set,From,PARAMS'
BY CURR_VALUE
BY VALUE AS 'Available,Values'
BY VALDESC
BY IS_DEFAULT
WHERE SETNAME EQ 'WEEKFIRST';
ON TABLE SET PAGE-NUM OFF
END  


Hallway

 
Prod: 8202M1
Test: 8202M4
Repository:
 
OS:
 
Outputs:
 
 
 
 
 
Posts: 608 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Report This Post
Expert
posted Hide Post
Thanks Guys. It looks like WEEKFIRST = ISO2 is the winner, I need Jan 1 to be the start of week 1.
Here's my results based on the great info from J.Gross and Hallway:
DTPART Test: WEEKFIRST = 1			DTPART Test: WEEKFIRST = ISO1			DTPART Test: WEEKFIRST = ISO2
20171228	52	Day	5		20171228	52	Day	5		20171228	52	Day	4
20171229	52	Day	6		20171229	52	Day	6		20171229	52	Day	5
20171230	52	Day	7		20171230	52	Day	7		20171230	52	Day	6
20171231	53	Day	1		20171231	1	Day	1		20171231	52	Day	7
20180101	53	Day	2		20180101	1	Day	2		20180101	1	Day	1
20180102	53	Day	3		20180102	1	Day	3		20180102	1	Day	2
20180103	53	Day	4		20180103	1	Day	4		20180103	1	Day	3
20180104	53	Day	5		20180104	1	Day	5		20180104	1	Day	4
20180105	53	Day	6		20180105	1	Day	6		20180105	1	Day	5
20180106	53	Day	7		20180106	1	Day	7		20180106	1	Day	6
20180107	1	Day	1		20180107	2	Day	1		20180107	1	Day	7
20180108	1	Day	2		20180108	2	Day	2		20180108	2	Day	1
20181026	42	Day	6		20181026	43	Day	6		20181026	43	Day	5
20181027	42	Day	7		20181027	43	Day	7		20181027	43	Day	6
20181028	43	Day	1		20181028	44	Day	1		20181028	43	Day	7
20181029	43	Day	2		20181029	44	Day	2		20181029	44	Day	1
20181030	43	Day	3		20181030	44	Day	3		20181030	44	Day	2
20181031	43	Day	4		20181031	44	Day	4		20181031	44	Day	3

SET WEEKFIRST: Start of week for date/datetime functions' WEEK and WEEKDAY components.	
DEFAULT 1 ... Current Value: ISO2	
Values	Available Value Description
0	No setting.
1	Sunday, non-standard week numbering.
2	Monday, non-standard week numbering.
3	Tuesday, non-standard week numbering.
4	Wednesday, non-standard week numbering.
5	Thursday, non-standard week numbering.
6	Friday, non-standard week numbering.
7	Saturday, non-standard week numbering.
ISO	ISO standard establishes Monday as 1st day of week, so allow alternate of ISO for ISO2.
ISO1	Sunday, ISO standard week numbering.
ISO2	Monday, ISO standard week numbering.
ISO3	Tuesday, ISO standard week numbering.
ISO4	Wednesday, ISO standard week numbering.
ISO5	Thursday, ISO standard week numbering.
ISO6	Friday, ISO standard week numbering.
ISO7	Saturday, ISO standard week numbering.
SIMPLE	simple week numbering.
STD	Sunday, standard week numbering, alternate for STD1.
STD1	Sunday, standard week numbering.
STD2	Monday, standard week numbering.
STD3	Tuesday, standard week numbering.
STD4	Wednesday, standard week numbering.
STD5	Thursday, standard week numbering.
STD6	Friday, standard week numbering.
STD7	Saturday, standard week numbering.

It looks like Focal Point came thru, No Surprise There, and I don't need to open a case. Smiler

This message has been edited. Last edited by: Doug,
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Master
posted Hide Post
quote:
...? SET WEEKFIRST
It shows as "WEEKFIRST 0"
However, I ran that same report with the following code prepended to it, and got the same results. ? SET WEEKFIRST
-RUN
SET WEEKFIRST = 1...

Oh, ok, that is the issue then.

If the value is '0' then the default is used. And the default for '0' is Sunday (as if you had set the value to 1).

Sounds like you have a requirement that Monday is the first day of the week.

If that is the case SET WEEKFIRST to 2 as I show. (Or ISO2 if you would like ISO standard week processing.)
 
Posts: 822 | Registered: April 23, 2003Report This Post
Expert
posted Hide Post
Yes Sir, my requirement WAS that Monday is the first day of the week. Now it's Sunday.

So, I could use 1, ISO1, or STD1. I chose ISO1.
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 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     [SOLVED] DTPART Issue?

Copyright © 1996-2020 Information Builders