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] Working with date ranges based on Period

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Working with date ranges based on Period
 Login/Join
 
Member
posted
I am working on some accounting reports that take as parameters YEAR and MONTH for the data selection. But some of the tables I am working with use date fiels so I need to create a couple of variable that can have a start and end date for the where statement. Could someone help me with a function that might work so I can create those dates using as parameters the YEAR and MONTH?

Example:
YEAR:2009
MONTH:2
I need to have:
STARTDATE=? (1/1/2009)
ENDDATE=? (1/28/2009)

Thanks,

Rafael Rangel

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


Rafa
 
Posts: 9 | Location: Memphis, TN | Registered: March 09, 2007Report This Post
Platinum Member
posted Hide Post
Rafael,

I think use DATEMOV yes? Have month year add 1 for month/1/year as BOM then DATEMOV EOM? Simple No?

Kofi


Client Server 8.1.05: Apache; Tomcat;Windows Server 2012
Reporting Server 8.1.05; Oracle; MS SQL; Windows Server 2012
 
Posts: 106 | Registered: April 06, 2009Report This Post
Expert
posted Hide Post
Is the parameter for MONTH being passed as 2 or 02?
If you can control the parameter list, its best to pass it as 02
then what field format is your date field in in your database, for the WHERE compare?
-SET &MYDATE = &MYYEAR | &MYMONTH | '01';
The DATEMOV function will then give you the last day of that given month, as , ahem, 'Kofi' says ; There are a couple of other ways to do that, as well.
But you have to know what your target format needs to be, to match your database field format.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Virtuoso
posted Hide Post
Aha, you meant to say 2/1/2009 and 2/28/2009... or better: you want the first and last day of the month for a given month.

Kofi and Susannah are both right. Use DATMOV or any other method that suits your needs. There are many ways to get where you need to be...


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report This Post
Virtuoso
posted Hide Post
and to learn more on date manipulation you might be interested in buying the book
"almost 1001 ways to work with dates...."




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Member
posted Hide Post
I am still having problems with this.I did the following as per Susannah's suggestion:

quote:
-DEFAULT &RPTYEAR='2009'
-DEFAULT &RPTMONTH='03'

-SET &STARTDATE = &RPTYEAR | &RPTMONTH | '01';
-SET &ENDDATE = DATEMOV (&STARTDATE, 'EOM');


The query is taking ok the &STARTDATE, but &ENDDATE is not working as it fails and I get the following error:

THE FORMAT OF THE TEST VALUE IS INCONSISTENT WITH FIELD FORMAT:
********

I think this is happening because WF thinks &ENDDATE Iis a character string and not a date.

Any ideas?

Thanks,

Rafael


Rafa
 
Posts: 9 | Location: Memphis, TN | Registered: March 09, 2007Report This Post
Expert
posted Hide Post
Check out Francis' reply (2nd from last) in this post:
http://forums.informationbuild...941036171#5941036171

This will do exactly what you want.

DATEMOV requires a smart date. Using functions with Dialogue Manager variables requires formats to be specified in the parameters for the function.

You might want to do some reading in the "Using Functions" manual.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
 
Posts: 2723 | Location: Ann Arbor, MI | Registered: April 05, 2006Report This Post
Platinum Member
posted Hide Post
This is the technique I use -- it's the "old" way of coding but it works great. In the below code I'm passing in a year (&DPYEAR) and a month (&DPERIOD). I use the IMOD() function on the year to determine if the value passed in for year is a leap year or not. I then check the value passed in for month and set my &var &EOM to the correct value. I then concatenate the three fields together -- this snippet of code is wrapped into a loop in my fex -- you can just remove the .&ctr to use it not in a loop. Hope this helps.
  
-SET &REMAINDER = IMOD(&DPYEAR, 4, 'I3L');
-SET &EOM.&CTR = IF (&DPERIOD.&CTR EQ '02') AND (&REMAINDER EQ 0) THEN '29' ELSE
- IF (&DPERIOD.&CTR EQ '02') AND (&REMAINDER NE 0) THEN '28' ELSE
- IF (&DPERIOD.&CTR EQ '01' OR '03' OR '05' OR '07' OR '08' OR '10' OR '12') THEN '31' ELSE '30';
-SET &EDPYMD.&CTR = &DPYEAR | &DPERIOD.&CTR | &EOM.&CTR ;



WF 7.7.05
HP-UX - Reporting Server, Windows 2008 - Client, MSSQL 2008, FOCUS Databases, Flat Files
HTML, Excel, PDF
 
Posts: 149 | Location: Dallas, TX | Registered: June 08, 2007Report This Post
Master
posted Hide Post
Another "old" way and you don't have to worry about leap year or days per month.

 
-SET &ECHO=ALL;
-DEFAULT &RPTYEAR='2009'
-DEFAULT &RPTMONTH='03'
-SET &STARTYYM=&RPTYEAR | &RPTMONTH;
-SET &NEXTMO=AYM(&STARTYYM, 1, 'I6YYM');
-SET &NEXTYYMD='&NEXTMO.EVAL'|'01';
-SET &STARTDATE = &RPTYEAR | &RPTMONTH | '01';
-SET &ENDDATE = AYMD (&NEXTYYMD,-1,'I8YYMD'); 
-TYPE &ENDDATE &STARTDATE
 


Pat
WF 7.6.8, AIX, AS400, NT
AS400 FOCUS, AIX FOCUS,
Oracle, DB2, JDE, Lotus Notes
 
Posts: 755 | Location: TX | Registered: September 25, 2007Report This Post
Member
posted Hide Post
I ended up going for PBrightwell's solution. It works like a charm.

Thank you everybody for your help.

Rafael

BTW - I ordered the 1001 ways to work with dates book. This seemingly simple stuff was driving me crazy.
 
Posts: 9 | Location: Memphis, TN | Registered: March 09, 2007Report 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] Working with date ranges based on Period

Copyright © 1996-2020 Information Builders