OUTPUT = I5_____2This message has been edited. Last edited by: Charles Richards,
WebFOCUS 7.6 Windows, All Outputs
July 12, 2011, 02:09 PM
j.gross
In Dialog Manager, or in Reporting Language (Define)?
How do you want to handle cases where the difference is not an exact multiple of seven days?
July 12, 2011, 03:32 PM
Charles Richards
i would just like it to be rounded to the nearest integer, and a define would work!
ex 3/7 =0 4/7 =1
WebFOCUS 7.6 Windows, All Outputs
July 12, 2011, 03:52 PM
FrankDutch
subtracting dates can be done in many ways but as j.gross asked it depends if it are database fields or DM values.
please try to get the book "1001 ...." it helps a lot in date issues.
the rounding issue was posted by me with a function you can use.
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
July 12, 2011, 03:59 PM
Francis Mariani
I would use the DATEDIF function to determine the number of days between the two dates, then divide by 7 to determine the number of weeks.
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
July 12, 2011, 04:10 PM
Dan Satchell
Or you could use legacy date function DAMDY. However, this approach assumes the input dates are always in the format 'mm/dd/yyyy', including leading zeroes.
I used the above line in my define and it doesn't seem to work, I can't seem to get this define working, is there an alturnative way, like calculating it with a compute?
INPUT
&SDATE &EDATE
WebFOCUS 7.6 Windows, All Outputs
July 18, 2011, 09:55 AM
Francis Mariani
quote:
it doesn't seem to work, I can't seem to get this define working
When this occurs, it's helpful to tell us what error or incorrect result you got.
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
July 18, 2011, 03:07 PM
Charles Richards
it calculates it to be either a 0 or .00, when i should be getting a 1.
&SDATE = 4/30/2011 &EDATE = 5/6/2011
WebFOCUS 7.6 Windows, All Outputs
July 18, 2011, 03:17 PM
Prarie
Isn't that because the difference between those dates is 6?
July 18, 2011, 03:25 PM
Dan Satchell
If you want a DEFINE/COMPUTE, try something like this:
-SET &SDATE = '4/30/2011';
-SET &EDATE = '5/6/2011';
-*
DEFINE FILE CAR
SDATE/MDYY WITH COUNTRY = '&SDATE';
EDATE/MDYY WITH COUNTRY = '&EDATE';
WEEK_DIFF/F3 = (DATEDIF(SDATE,EDATE,'D')) / 7 ;
END
-*
TABLE FILE CAR
PRINT SDATE EDATE WEEK_DIFF
WHERE RECORDLIMIT EQ 1 ;
END
This message has been edited. Last edited by: Dan Satchell,
WebFOCUS 7.7.05
July 18, 2011, 03:33 PM
Charles Richards
SDATE/MDYY WITH COUNTRY = '&SDATE';
what does the "WITH COUNTRY" mean?This message has been edited. Last edited by: Charles Richards,
WebFOCUS 7.6 Windows, All Outputs
July 18, 2011, 03:43 PM
Dan Satchell
Remove it and find out. In multi-segment files (like the CAR file) DEFINEs must reference a real field, a previously defined field, or must have an explicit field reference (e.g., 'WITH COUNTRY'). Otherwise FOCUS does not know to which segment it should attach the DEFINEd field.This message has been edited. Last edited by: Dan Satchell,
WebFOCUS 7.7.05
July 19, 2011, 11:08 AM
Charles Richards
I can't figure out what i seem to be doing wrong...
I am running the fex file and added the define variable WKS int the header as latest attempt:
Im still recieveing a 0 as the output, i even took the " / 7 " (divid by seven) out just to see if i get the difference in days and still a 0. I put the varible SDATE and EDATE in the header just to see what is getting put in them and the dates look exactly how they are suppose to, I don't know what I am doing wrong...
UPDATE: it seems to be working, but the output is 5,727
for SDATE 04/30/2011 EDATE 05/06/2011This message has been edited. Last edited by: Charles Richards,
WebFOCUS 7.6 Windows, All Outputs
July 19, 2011, 01:57 PM
Dan Satchell
I believe 5,727 is the number of weeks between 1/1/1901 and 5/6/2011. So it appears your code is using 1/1/1901 for SDATE instead of 4/30/2011. This would indicate an error somewhere in the code that handles the incoming value for &SDATE. The value for SDATE is therefore defaulting to the FOCUS base date of 1/1/1901. Put the following statement at the top of your program so you can see what is happening in your code.
-SET &ECHO = ALL ;
WebFOCUS 7.7.05
July 19, 2011, 03:17 PM
Charles Richards
ok I added that in, but it only works upon an error...
I added this to the header to see the values "< WKS" "< SDATE < EDATE"
and it is giving me
5,727 04/30/2011 05/06/2011
so It appears to be using the correct values
WebFOCUS 7.6 Windows, All Outputs
July 19, 2011, 03:59 PM
Francis Mariani
Works in this test fex:
-SET &SDATE = '04/30/2011';
-SET &EDATE = '05/06/2011';
DEFINE FILE CAR
SDATE/MDYY = '&SDATE';
EDATE/MDYY = '&EDATE';
WKS/D8 = (DATEDIF(SDATE,EDATE,'D')) / 7 ;
END
-RUN
TABLE FILE CAR
PRINT
SDATE
EDATE
WKS
BY COUNTRY
WHERE RECORDLIMIT EQ 1
END
-RUN
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
July 19, 2011, 04:35 PM
RSquared
Have you tried using the HDIFF function. It has a type of 'WEEK'?
WF 7.6.11 Oracle WebSphere Windows NT-5.2 x86 32bit
July 20, 2011, 09:16 AM
MLM
Hello charles you might want to check the date output from the date control, it gives you the option to automatically pass the date as yyyymmdd otherwise you have to convert the date from mm/dd/yyyy to yyyymmdd then use the datedif function.
I sometimes forget about my WF environment settings. For the code below to work, DMPRECISION must be set to zero so Dialogue Manager will round up instead of truncating decimals. With DMPRECISION=0, both of these examples should work.