Focal Point
HPART Problems

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

July 07, 2004, 04:07 PM
Lloyd
HPART Problems
Hi Guys, I'm having some trouble calcualting dates using the hpart function. The following code seems to only generate zero's for the HPART functions. Any Ideas why?




WK_DATE/YYMD = &YYMD;
BASEDATE/YYMD=DATECVT(20040101,'I8YYMD', 'YYMD');

WK_MONTH/I2 = HPART(WK_DATE,'MONTH','I2');
WK_DAY/I2 = HPART(WK_DATE,'DAY','I2');
WK_YEAR/I4 = HPART(WK_DATE,'YEAR','I4');


SALES_WEEK/I5 = HPART(WK_DATE, 'WEEK', 'I5');
SALES_WK/I5 = (DATEDIF( BASEDATE, WK_DATE,'D') + 1) / 7 ;

Thanks, Lloyd

This message has been edited. Last edited by: <Mabel>,
July 07, 2004, 05:57 PM
jmdoyl1
Loyd,

I think the problem is that the HPART is expecting a DATE-TIME value and you are only supplying a DATE value. I tried the following and was able to get the HPART function to work:

WK_DATE2/HYYMDIA = DT(&YYMD.EVAL 09:00AM);
WK_MONTH/I2 = HPART(WK_DATE2 ,'MONTH','I2');

Then I got the Month to show up in the report.

Jon
July 07, 2004, 06:01 PM
jimster06
Lloyd-
You are on the right track. The HPART function assumes that you are using an H form date/time variable. Put your WK_DATE and BASEDATE variables into H form such as HYYMDs and then work from there.
Take a look at how HCNVRT and HINPUT are used in the WF Function manual, p7-42, WF5.2.