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] Get Week Number from Date in YYMD Format

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Get Week Number from Date in YYMD Format
 Login/Join
 
Gold member
posted
I am trying to get the week number, or even ISO date. The original field was in Julian (YYYYDDD) format. I have that converted it to Gregorian (YYMD) format.
Using the 'Help' section in Dev Studio, I found the section on HYYWD.
COMPUTE ISODATE/A10 = HYYWD(TRANSDATE, 'A10');
COMPUTE WEEK/A2 = EDIT(ISODATE, '$$$$$$99$$');
I've tried using EDIT to edit the format of my date from YYMD to HYYWD, but that's not working at all. I was thinking about concatenating a time on the end of my date, but there should be a way to convert using just the date without a time. Help!

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


WebFOCUS 768
OS/400
HTML, also quite a few active reports and excel.
 
Posts: 59 | Registered: June 18, 2009Report This Post
Gold member
posted Hide Post
From what I recall to work with weeks its best to use a DateTime calculation. I believe the -SET WEEKFIRST only works with the DateTime functions. You can control what day is the start of the week and IIR they have recently fixed some of the ISO discrepancies with it. Now there is 1-7 and ISO1-ISO7.

I'm starting with &YYMD which is I8YYMD format.

 COMPUTE CUR_DATETIME/HMDYYS = HDTTM(DATECVT(&YYMD,'I8YYMD','YYMD'),8,'HMDYYS');
 COMPUTE CUR_WEEK_NO/I2 = HPART(CUR_DATETIME,'WEEK','I2');


This should output the week number in I2 format based on the WEEKFIRST setting.

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


------------------------------------------
DevStudio 8.2.03
WFS 8.2.03
 
Posts: 86 | Location: Atlanta | Registered: May 10, 2007Report This Post
Gold member
posted Hide Post
DOWK AND DOWK returns the day of week and I believe Amber is looking for the actual week number of the year.

Amber,
I changed my code to include moving from an INT date to datetime, then from datetime to week number.

If your going to be working with dates I would recommend getting familiar with DATECVT if you are not already. It has to be my most used function when working with dates.

Also, just curious. I see your on OS/400, what is the source (application) of your original date field?


------------------------------------------
DevStudio 8.2.03
WFS 8.2.03
 
Posts: 86 | Location: Atlanta | Registered: May 10, 2007Report This Post
Expert
posted Hide Post
Thanks for the heads up on the DOW thing Trob, I removed it...

Keep in mind that these COMPUTEs (Posted Thu Jun 18 2009 16:00) are based on week one being the first FULL week of the year. Check it out with the EMPLOYEE file / HIRE_DATE and see what week Richard Smith was hired (Monday 01/04/1982). This says Week One, based on the first full week in 1982. 1/1/1982 is Friday of the previous week. I've been at places that required that week one was based on the first day of the year. If so, some trickery may be required. The code which shows this is available.
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Gold member
posted Hide Post
quote:
Originally posted by Doug:
Thanks for the heads up on the DOW thing Trob, I removed it...

Keep in mind that these COMPUTEs (Posted Thu Jun 18 2009 16:00) are based on week one being the first FULL week of the year. Check it out with the EMPLOYEE file / HIRE_DATE and see what week Richard Smith was hired (Monday 01/04/1982). This says Week One, based on the first full week in 1982. 1/1/1982 is Friday of the previous week. I've been at places that required that week one was based on the first day of the year. If so, some trickery may be required. The code which shows this is available.


Nice point Doug. This is why they added the ISO1-ISO7. About a year and a half ago when I wanted to use ISO for week number it was broken but now its fixed. ISO 8601 standard week numbering defines the first week of the year as the first week in January with four or more days. It use to only work for the first week in January with seven days. That always made every day of week one a January date. With ISO week 1 can contain the last three days of December. Coding around that sucked at the time. Thank you IBI!

ISO is a synonym for ISO2 which is the ISO standard which establishes Monday as the first day of the week.


------------------------------------------
DevStudio 8.2.03
WFS 8.2.03
 
Posts: 86 | Location: Atlanta | Registered: May 10, 2007Report This Post
Expert
posted Hide Post
So, it comes down to what ISO do you want? Take your pick... You should have enough information now to get you going, right?
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Gold member
posted Hide Post
Yes sir(s) I have. I ended up using:

HRDT1/I8YYMD=GREGDT(DRHDAT, 'I8YYMD');
HRDT2/MDYY=HRDT1;
HRDT3/HYYMDS=HDTTM(HRDT2, 8, 'HYYMDS');
HRWK1/I2=HPART(HRDT3,'WEEK','I2');

DRHDAT is my Julian Date from the 400 (YYYDDD).

Thanks for all your help!!


WebFOCUS 768
OS/400
HTML, also quite a few active reports and excel.
 
Posts: 59 | Registered: June 18, 2009Report This Post
Gold member
posted Hide Post
quote:
DRHDAT is my Julian Date from the 400 (YYYDDD).

Ok.
I was just wondering because we are on JDEdwards and all the dating in a modified julian format. Prior to Y2K fixes date fields were YYDDD however now it uses CYYDDD. C is 0 for years before 2000 and 1 for 2000 through 2099. Today is 109170.

Having to handle dates so often I found it well worth it to create a function on the server "JDETOSD()", which I pass it a JDE Julian Date and it returns a SmartDate.


------------------------------------------
DevStudio 8.2.03
WFS 8.2.03
 
Posts: 86 | Location: Atlanta | Registered: May 10, 2007Report This Post
Expert
posted Hide Post
Trob: Would you care to share th JDETOSD function with us, All the FocalPoint user?
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Gold member
posted Hide Post
quote:
Originally posted by Doug:
Trob: Would you care to share th JDETOSD function with us, All the FocalPoint user?

Handling JDEdwards dates


------------------------------------------
DevStudio 8.2.03
WFS 8.2.03
 
Posts: 86 | Location: Atlanta | Registered: May 10, 2007Report This Post
Expert
posted Hide Post
Thanks trob...
 
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] Get Week Number from Date in YYMD Format

Copyright © 1996-2020 Information Builders