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
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
In FOCUS Since 1983 ~ from FOCUS to WebFOCUS. Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206 |
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 ENDWith 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 2It looks like Week 53 is a carry-over from 2017. Should that be?This message has been edited. Last edited by: Doug,
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
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
? SET WEEKFIRST -RUN SET WEEKFIRST = 1 -RUN ? SET WEEKFIRST -EXITThe final result of the "? SET WEEKFIRST" shows it as 1. Could it be a DTPART routine issue not recognizing the setting of weekfirst?
BabakNYC ... Me too ... Even with the SET WEEKFIRST ...quote:I'd love to know IB's explanation.
In FOCUS Since 1983 ~ from FOCUS to WebFOCUS. Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206 |
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?
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
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
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.
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...