Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Go
New
Search
Notify
Tools
Reply
  
HPART Problems
 Login/Join
 
Platinum Member
posted
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>,
 
Posts: 157 | Location: Secaucus, NJ | Registered: May 21, 2004Reply With QuoteReport This Post
Silver Member
posted Hide Post
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
 
Posts: 39 | Registered: January 26, 2004Reply With QuoteReport This Post
Guru
posted Hide Post
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.
 
Posts: 252 | Location: USA | Registered: April 15, 2003Reply With QuoteReport This Post
  Powered by Social Strata  
 


Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.