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.
I'm looking to run a report for last Monday to last Sunday. I'm thinking I'll determine this week's number, subtract one, determine the Beginning of Week of that week, then determine the End of Week of that week. Is this the proper approach and how would I write such code?
-SET &TODAY = &YYMD; -*THE FORMAT OF YOUR DATES MAY BE DIFFERENT; -SET &FROMDT = &TODAY - 11; -*TODAY IS FRIDAY 7/13 SO LAST MONDAY IS 11 DAYS AGO; -SET &THRUDT = &TODAY - 5; -*TODAY IS FRIDAY 7/13 SO LAST SUNDAY IS 5 DAYS AGO; UNIX echo &FROMDT UNIX echo &THRUDT TABLE FILE FILENAME PRINT * WHERE DATEFIELD EQ &FROMDT WHERE DATEFIELD EQ &THRUDT END
The reason for the LT '&ENDDT' is because many databases (ours being Oracle), date fields are really datetime fields. If you define a datetime field as YYMD,DATE in the .mas and use LE with a date, you won't get any dates after midnight if the WHERE clause is passed to the database. For example, if you used &ENDDT as 20070714, then all the dates for Saturday fail the LE '20070714' test if they have any time except midnight (00:00:00.00000).
Now if your .mas has the dates defined as HYYMDS (datetime), the WHERE clause becomes:
WHERE TESTDT GE HINPUT(8,'&BEGDT',8, 'HYYMDS') AND TESTDT LT HINPUT(8,'&ENDDT',8, 'HYYMDS')
The problem with this is that because of the use of the HINPUT function, the WHERE clause does not get passed to the data base. To avoid this I usually find it usefull to have a single database date fields defined as 2 fields in the .mas, one as smart date and the other as datetime.This message has been edited. Last edited by: jgelona,
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, 2006
Thanks... It's always nice to have place to come to thaw out your brain when you have some brain-freeze... This has been around since Jul 16 2007 and is still as good as ever...
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005
Originally posted by WinstonSmith6076: I'm looking to run a report for last Monday to last Sunday. I'm thinking I'll determine this week's number, subtract one, determine the Beginning of Week of that week, then determine the End of Week of that week. Is this the proper approach and how would I write such code?
And what if you'd do that in week 1? ALWAYS use date arithmetic functions to modify dates.
In this case you could use DATEADD or HADD (depending on the type of date) to add -(DOWK + 7 -1) days.
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 :
yep, but datemov doesn't seem to work on &vars, tho. alas.
This is true, and documented. I have got into the habit now of using routines based around multiple date and date time functions. These seem to work well, so keeps me happy!