Focal Point
Defining or computing a number based on dates

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5901036102

December 15, 2006, 12:21 PM
jcs1226
Defining or computing a number based on dates
Hi everyone,
I am attempting to create a number in days (&END1 - &BEG1) so I can use it for calcuations such as per day stats in my report.
I used a define:

DEFINE FILE CHGDTL2
DAYS_PER/I5 = (&END1 - &BEG1);

But I am getting a much higher number than it should be. For instance I get 129 when the number should be 61. Also if its important, at the end of the report I am placing this character (DAYS_PER) in the footer.

FOOTING BOTTOM
"
Any ideas?

Thank you.


WebFocus 7.6.6 Win 2K
December 15, 2006, 01:13 PM
N.Selph
What format are your dates in?
Date arithmetic is done differently for different date types.


(Prod: WebFOCUS 7.7.03: Win 2008 & AIX hub/Servlet Mode; sub: AS/400 JDE; mostly Self Serve; DBs: Oracle, JDE, SQLServer; various output formats)
December 18, 2006, 10:46 AM
jcs1226
Hi N.Selph,
The format of the field is P9. I will try changing this format to a date format and see if that works. Do you have suggestions on a particular date format? Thanks for the response.


WebFocus 7.6.6 Win 2K
December 18, 2006, 02:25 PM
N.Selph
Is this an input field or coming from or matching some data source? If it is an input field you should convert it to the date data type you use in your data source for more effective data retrieval.
In the P9 field - it will be effectivly some kind of date - either a Julian, offset date (ie an integer such as a Smart Date) or something like 20061218 - Integer legacy date. Depending on what it is, it is easiest for you to "convert" it (define it to WebFocus) to the one it naturally already is.
If you can convert it to a Smart date format (YYMD), then you can subtract directly just like you are, and the formula will work. Or you can use the DATEDIF function.
If you have an integer legacy date (I8YYMD), you will need to use the YMD function:
 
DAYS_PER/I5=YMD(&BEG1,&END1,'I5');
 



(Prod: WebFOCUS 7.7.03: Win 2008 & AIX hub/Servlet Mode; sub: AS/400 JDE; mostly Self Serve; DBs: Oracle, JDE, SQLServer; various output formats)
February 22, 2007, 06:03 PM
jcs1226
Sorry for the delay but wanted to post an update. I found that N. Selph was dead on! It was in P9 format so was basically subtracting the numbers rather than the dates (i.e. subtracting 20070222 - 20070101 = 121). So long as BEG1 and END1 are in the same month no problem, otherwise would need to convert as N. Selph suggested. Thanks for the help!!!


WebFocus 7.6.6 Win 2K