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;
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, LloydThis message has been edited. Last edited by: <Mabel>,
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.
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.
|Powered by Social Strata|