Focal Point
HPART revisited

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

August 12, 2004, 06:30 PM
Lloyd
HPART revisited
hi all, having yet another problem with hpart. It seems that weekfirst doesn't have any effect on the week being returned when using hpart. The following is a test I did changing weekfirst through all the setting (1-7) and nothing was different. Any body know if I missing something or if this is problem that needs to be fixed?

here's the code:


-SET WEEKFIRST = 1;
DEFINE FILE CASHFLOW

RDATE1/HYYMD = DT(20040804 12:00:00);
RDATE2/HYYMD = DT(20040805 12:00:00);
RDATE3/HYYMD = DT(20040806 12:00:00);
RDATE4/HYYMD = DT(20040807 12:00:00);
-*
RDATE1_WEEK/I3 = HPART(RDATE1, 'WEEK', 'I3');
RDATE2_WEEK/I3 = HPART(RDATE2, 'WEEK', 'I3');
RDATE3_WEEK/I3 = HPART(RDATE3, 'WEEK', 'I3');
RDATE4_WEEK/I3 = HPART(RDATE4, 'WEEK', 'I3');
-*
END

TABLE FILE CASHFLOW
-* Generated by Report Assist
PRINT CASH_DATE RDATE1 RDATE1_WEEK RDATE2 RDATE2_WEEK RDATE3 RDATE3_WEEK RDATE4 RDATE4_WEEK
ON TABLE SET ONLINE-FMT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET PAGE-NUM OFF
ON TABLE SET STYLE DEFLT
END
here's my output:


Date of
Statement RDATE1 RDATE1_WEEK RDATE2 RDATE2_WEEK RDATE3 RDATE3_WEEK RDATE4 RDATE4_WEEK
01/02/1997 2004/08/04 31 2004/08/05 31 2004/08/06 31 2004/08/07 32
01/03/1997 2004/08/04 31 2004/08/05 31 2004/08/06 31 2004/08/07 32
01/04/1997 2004/08/04 31 2004/08/05 31 2004/08/06 31 2004/08/07 32

This message has been edited. Last edited by: <Mabel>,
August 12, 2004, 06:51 PM
susannah
um, August 4,5,6, and 7 are all in week 31, so i don't see a prob. Can you explain what it is you expect to see?
August 12, 2004, 07:03 PM
Lloyd
IF YOU LOOK, IT PUTS 8/07 IN WEEK 32.
August 12, 2004, 07:42 PM
susannah
oh, yeah i see that now. it ran off my screen.
The Variable WEEKFIRST is a system var and you're making it an amper var, sort of.
Take the dash out.
SET WEEKFIRST = 1
August 12, 2004, 08:33 PM
Lloyd
yeah, I was trying every way possible and that must have been my last trial. I just tried it all again and there was no difference.

is it possible that there is a system default?
August 12, 2004, 09:08 PM
<Pietro De Santis>
Well, it looks like Sunday is not the first day of the week by default.

Add the following to the program and it should work:

SET WEEKFIRST=1
quote:
Specifies a day of the week as the start of the week. This is used in week computations
by the HDIFF, HNAME, HPART, and HSETPT functions.
The WEEKFIRST parameter does not change the day of the month that corresponds to
each day of the week, but only specifies which day is considered the start of the week.
quote:
SET WEEKFIRST = { n|7}
where:
n
Is a number from one to seven, where one represents Sunday and seven
represents Saturday. The default value is seven, which is consistent with the
Microsoft SQL Server convention.
Pietro.
August 12, 2004, 09:14 PM
Lloyd
hey pietro, if you follow my code above, you'll see that I tried that. Don't mind the '-' in front of the set statement, that was just a trial that failed. I tried every value and nothing seemed to change. By default I mean a system override that will ignore the code.
August 12, 2004, 09:24 PM
<Pietro De Santis>
Interesting, because, when I added the weekfirst command, it worked:


SET WEEKFIRST=1

DEFINE FILE CAR
RDATE1/HYYMD = DT(20040804 0:00:00);
RDATE2/HYYMD = DT(20040805 0:00:00);
RDATE3/HYYMD = DT(20040806 0:00:00);
RDATE4/HYYMD = DT(20040807 0:00:00);
RDATE1_WEEK/I2 = HPART(RDATE1, 'WEEK', 'I2');
RDATE2_WEEK/I2 = HPART(RDATE2, 'WEEK', 'I2');
RDATE3_WEEK/I2 = HPART(RDATE3, 'WEEK', 'I2');
RDATE4_WEEK/I2 = HPART(RDATE4, 'WEEK', 'I2');
END

TABLE FILE CAR
PRINT
MODEL NOPRINT
RDATE1 RDATE1_WEEK
RDATE2 RDATE2_WEEK
RDATE3 RDATE3_WEEK
RDATE4 RDATE4_WEEK
END

This message has been edited. Last edited by: <Mabel>,
August 12, 2004, 09:57 PM
Lloyd
see there you go again helping me when I'm stuck. You would'nt beleive what the problem was! it was the semi-colon after the weekfirst statement. I took it out and everything worked the way it should of.


Wheww....thought I was going crazy,...actually I was...