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.



Read-Only Read-Only Topic
Go
Search
Notify
Tools
calculation date
 Login/Join
 
<mbribeche>
posted
Like Julian date for the number of current day, I could calculate the number of the current week. Somedoby can help me !

Roll Eyes
 
Report This Post
Guru
posted Hide Post
Look at WebFOCUS' various date functions. Julian date, week number, etc are available.
 
Posts: 252 | Location: USA | Registered: April 15, 2003Report This Post
Guru
posted Hide Post
Another word or two:
There is date conversion function JULDATE that will convert YYMD or YMD format dates to YYYYJUL or YYJUL.
Another function, JULIAN, will extract the number of days from January 1 in the variable DATE and return an integer value.
The calculation of week number, a variable often used in retailing, takes a couple of steps. First, the Julian value of week 0 must be known; this probably varies by calendar year. Next, find the julian value of the current DATE. Subtract first from the second and divide the result by 7 to get the number of weeks from week 0. If you cross a year boundary, another step or two would be necessary.
 
Posts: 252 | Location: USA | Registered: April 15, 2003Report This Post
Expert
posted Hide Post
Jimster06, WEEK number isn't available as a focus function. Whats available is /W, which is the day of the week, 1-7 (or is it 0-6, whatever );
Week number is a very important field in Retail, and we calculate it depending on the way of the week that "OUR" week begins. Different for Different retailers.
So, Week Number is a calculation, using
1) the Smart Date for Jan 1 of the current year,
2) figuring out what day of the week that is.
3) adjusting that smart date value either back a partial week or forward, depending on how we retailers count that partial week at the begining of a year.
4) taking today's smart date, figuring out what day of the week it is, adjusting to the beginning of our "week"
5) taking the difference between the two adjusted smart dates and dividing by 7.
That's how we do it.
It would, however, be great if ARt would write a UserWrittenSubRoutine to calculate week number, with those aguments. How about asking him for all of us out here in retail land.
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Platinum Member
posted Hide Post
The week number can be extracted from a date/time field by using HPART function.
(Available since WF43 and FOCUS 7.1, I think).

See the HPART available Doc.

Regards,
Mikel
 
Posts: 173 | Location: Madrid, Spain | Registered: May 09, 2003Report This Post
Guru
posted Hide Post
My bad. I should have referred to WEEKFIRST, HPART, and HNAME. But I do concur with Susannah's suggestion for a more robust week number calculation based my experience with an Arkansas-based retailer.
 
Posts: 252 | Location: USA | Registered: April 15, 2003Report This Post
Platinum Member
posted Hide Post
This is a piece of code I have recently written to calculate week numbers, since we're undergoing a major project where I currently work to change all the manufacturing systems from a Sunday-Saturday week to a Monday-Sunday week. Doesn't sound like such a big deal, except the first option gives us a week 53 this year (this was the original week numbering for this year) and now they want to change so there's only 52 weeks this year.


DEFINE FILE filename
DATE1/YYMD=fieldname;
DATE3/I8YYMD=DATE1;
DATE4/I8=DATE3;
WEEKDAY/A8 = DOWK(DATE4,WEEKDAY);
WED_DOWK/I1=DECODE WEEKDAY('MON' 2 'TUE' 3 'WED' 4 'THU' 5 'FRI' 6
'SAT' 7 'SUN' 1);
WED_DATE/YYMD=(DATE1 + 4)-WED_DOWK;
WED_DATE1/I8YYMD=WED_DATE;
WED_DATE2/I8=WED_DATE1;
WED_JULIAN_DATE/I5 = JULDAT(WED_DATE1, WED_JULIAN_DATE);
WED_JULIAN1/A5=EDIT(WED_JULIAN_DATE);
WED_JULIAN2/A3=EDIT(WED_JULIAN1, '$$999');
WED_JULIAN/I3=EDIT(WED_JULIAN2);
SUN_WEEK1/D7.2=WED_JULIAN/7;
SUN_WEEK2/A8=FTOA(SUN_WEEK1, '(D7.2)', SUN_WEEK2);
SUN_WEEK3/A2=EDIT(SUN_WEEK2, '$$$$$$99');
SUN_WEEKA/I3=WED_JULIAN/7;
SUN_WEEK/I3=IF SUN_WEEK3 EQ '00' THEN SUN_WEEKA ELSE SUN_WEEKA + 1;
THU_DOWK/I1=DECODE WEEKDAY('MON' 1 'TUE' 2 'WED' 3 'THU' 4 'FRI' 5
'SAT' 6 'SUN' 7);
THU_DATE/YYMD=(DATE1 + 4)-THU_DOWK;
THU_DATE1/I8YYMD=THU_DATE;
THU_DATE2/I8=THU_DATE1;
THU_JULIAN_DATE/I5 = JULDAT(THU_DATE1, THU_JULIAN_DATE);
THU_JULIAN1/A5=EDIT(THU_JULIAN_DATE);
THU_JULIAN2/A3=EDIT(THU_JULIAN1, '$$999');
THU_JULIAN/I3=EDIT(THU_JULIAN2);
THU_WEEK1/D7.2=THU_JULIAN/7;
THU_WEEK2/A8=FTOA(THU_WEEK1, '(D7.2)', THU_WEEK2);
THU_WEEK3/A2=EDIT(THU_WEEK2, '$$$$$$99');
THU_WEEKA/I3=THU_JULIAN/7;
MON_WEEK/I3=IF THU_WEEK3 EQ '00' THEN THU_WEEKA ELSE THU_WEEKA + 1;#
END
 
Posts: 123 | Location: UK | Registered: October 09, 2003Report This Post
Expert
posted Hide Post
That Hpart thing is cool.
Tewy, here's a way you can really shorten your code: To get the week number for today...
1.take the difference between today and the first day of the year (using smart dates)
2. divide that difference by 7
(gives you the current week number)
3.using the MOD function get the remainder from that division, and figure out how many days into the following week we are.
4. adjust your base date (the base of your subtraction) to accomodate whatever adjustments your company is requiring.
PRINT MYSMARTDATE AND
COMPUTE MYBASEDATE/YYMD=20030101;
COMPUTE DAYSTHISYR/I5=MYSMARTDATE - MYBASEDATE;
COMPUTE WEEKNUMBER/I4= DAYSTHISYR/7;
COMPUTE DAYSINTOWK/I4= IMOD(DAYSTHISYR,7,'I4');
i love working with smart dates.
they're just serial dates integer5 in form and math is breeze with them.
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Platinum Member
posted Hide Post
This is a perfect example of how I would use the new FOCUS option called DEFINE Function.

DEFINE FUNCTION name (parameter1/format1,..., parametern/formatn)
[tempvariablea/formata = expressiona;] . . .[tempvariablex/formatx = expressionx;]
name/format = [result_expression];
END

Its in the Reference Manual.
 
Posts: 226 | Registered: June 08, 2003Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic


Copyright © 1996-2020 Information Builders