Focal Point
[SOLVED] Sntax for using TODAY function in calculated field

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

February 28, 2014, 05:52 AM
tcox
[SOLVED] Sntax for using TODAY function in calculated field
Hi All.
Sorry for what is probably a simple question but I can't find any documentation on this.
I want to calculate the number of days between a date on my database and the current date. My db date is a date time field so I used HDATE to convert this.
Then I wanted to use DATEDIF to get the number of days between that date and the current date but the only way I could see of getting the current date was the TODAY function. However I put this into the DATEDIF function I get an error, usually along the lines of invalid argument for TODAY.

Can anyone help please?
Thank you...

This message has been edited. Last edited by: <Kathryn Henning>,


Release 8
Windows 7
Excel/HTML/PDF
Oracle 11g
March 02, 2014, 08:50 PM
StuBouyer
The problem iwth TODAY is that it returns an string representation of the date, which DATEDIF doesn't like.

I usually use the following:

DDFIF/I9 = DATEDIF('&YYMD', ORDER_DATE, 'Y');

OR

DDFIF/I9 = DATEDIF('&DATEYYMD', ORDER_DATE, 'Y');

Regards

Stuart


WebFOCUS 8.2.03 (8.2.06 in testing)
March 03, 2014, 03:27 PM
LTaylor
Hello - Perhaps this will help? The first set statement is used in an include member and may need a little reworking for this purpose...

-SET &Current_dt = HCNVRT(HGETC(10,'HYYMDm'),'(H20)',20,'A20');
CURDTTIM/HYYMDm = HINPUT(20, '&Current_dt', 8, CURDTTIM);
DIFF_DAYS/D10 = HDIFF(end_date_for_calculation, CURDTTIM, 'DAY', 'D10');


Production: WebFocus 8.0.09 Test: WebFocus 8.0.09 Windows, Z-Linux, and ZOS.
all output
Focus - 7.2.7
June 04, 2014, 04:28 AM
tcox
Thanks for the replies.
I checked both methods and could use either, but the requester decided they could do without that field on the report this time so I haven't had to choose.
At least I'll know for next time...


Release 8
Windows 7
Excel/HTML/PDF
Oracle 11g