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 DAY OF WEEK

Read-Only Read-Only Topic
Go
Search
Notify
Tools
***CLOSED DAY OF WEEK
 Login/Join
 
Master
posted
I have tried numerous things...none return me the numeric day of week that I can then decode to Mon/Tues/Wed etc.

The date is of type: HYYMDs. Must I perform a conversion of the date or can I get the DAY OF WEEK in one DEFINE?

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


WebFOCUS 8206.08
Windows, All Outputs
 
Posts: 603 | Registered: June 28, 2013Report This Post
Virtuoso
posted Hide Post
HPART and 'weekday' are what you need.

I wrote below function just yesterday to convert a year + week number to a date (Monday of the given week):
-*
-* Calculate the date to the beginning of the given week+year
-*
DEFINE FUNCTION WEEK2DATE(YEAR/P5, WEEK/P3)
-* January 1st
	IDATE/I8 	= YEAR * 10000 + 101;
	DATE/YYMD	= DATECVT(IDATE, 'I8YYMD', 'YYMD');
	DT/HYYMD 	= HDTTM(DATE, 8, DT);

-* Determine week 1 (as an offset to WEEK)
	WK/P3		= HPART(DT, 'week', WK);
	WK2/P3		= IF WK EQ 52 OR 53 THEN WEEK +1
					ELSE IF WK EQ 2 THEN WEEK -1
					ELSE WEEK;

-* Rewind date to Monday of that week
	WD/I2		= HPART(DT, 'weekday', WD);
	WD_DIFF/I2	= -IMOD(WD + 5, 7, WD_DIFF);
	DT2/HYYMD	= HADD(DT, 'day', WD_DIFF, 8, DT2);

-* Add WEEK -1 weeks
	DT3/HYYMD	= HADD(DT2, 'day', (WK2 -1) * 7, 8, DT3);

	WEEK2DATE/A20	= HCNVRT(DT3, '(HYYMDS)', 20, 'A20');
END


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Master
posted Hide Post
quote:
...return me the numeric day of week...the date is of type: HYYMDs...

Here is an example running against the AdventureWorks2014 sample MS SQL Server database. RATECHANGEDATE is a HYYMDs.
  RATECHANGEDATE           DAY_OF_WEEK                                          
  --------------           -----------                                          
  2009/01/14 00:00:00.000            4
  2008/01/31 00:00:00.000            5
  2007/11/11 00:00:00.000            1
  2007/12/05 00:00:00.000            4
  2010/05/31 00:00:00.000            2
  2011/12/15 00:00:00.000            5
  2008/01/06 00:00:00.000            1
  2008/01/24 00:00:00.000            5
  2009/02/08 00:00:00.000            1
  2008/12/29 00:00:00.000            2
  
-* File DayOfWeek.fex
SET OFFLINE-FMT = STANDARD
SET PAGE = NOPAGE
DEFINE FILE EMPLOYEEPAYHISTORY
 DAY_OF_WEEK/I2 = HPART(RATECHANGEDATE, 'DW', 'I2');
END
-* 
TABLE FILE EMPLOYEEPAYHISTORY
 PRINT RATECHANGEDATE DAY_OF_WEEK
 IF READLIMIT EQ 10
END  




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
Member
posted Hide Post
Why not just use pass thru SQL


Focus 7
 
Posts: 13 | Registered: May 17, 2015Report This Post
Master
posted Hide Post
quote:
DAY_OF_WEEK/I2 = HPART(RATECHANGEDATE, 'DW', 'I2');



David..I do believe this works...I had the function parameters wrong.

Jash - Thats Cheating! (just kidding)


WebFOCUS 8206.08
Windows, All Outputs
 
Posts: 603 | Registered: June 28, 2013Report This Post
Master
posted Hide Post
One thing I don't see a lot of here on Focal Point is using SQL functions in WebFOCUS code. For example (this is Oracle):

TABLE FILE XYZ
PRINT SQL.DAYOFWEEK(RATECHANGEDATE) AS DAYOFWEEK
END


We can now use any (or at least everyone I've tried) function that is valid for your database.

Another thing I do is when I have a date field like RATECHANGEDATE that has no time, I will change the format in the master from USAGE=HYYMDS, ACTUAL=HYYMDS to USAGE=YYMD, ACTUAL=DATE. Now I can use any smart date format without converting from date/time format to a smart date format, for example:

DAY_OF_WEEK/W=RATECHANGEDATE;


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
 
Posts: 975 | Location: Oklahoma City | Registered: October 27, 2006Report 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 DAY OF WEEK

Copyright © 1996-2020 Information Builders