Focal Point
[CLOSED] Can I build an HYYWD field from text?

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

May 17, 2018, 09:28 AM
John_Edwards
[CLOSED] Can I build an HYYWD field from text?
I have a text field with values in the form 2009-W05-01 in them, i.e., a text version of HYYWD. Is there a way to bring that into an HYYWD format field?

I tried HINPUT but it didn't produce a result:

The_Date/HYYMDs = HINPUT(10, WEEK_ATTENDED, 8, 'HYYMDs');

I get blanks, so it apparently isn't happy receiving that format as an input.

HSETPT maybe? Has anyone stumbled across this before?

This message has been edited. Last edited by: FP Mod Chuck,



May 17, 2018, 09:50 AM
John_Edwards
Alright, came up with this

The approach –
1. Make a date field, set to current date so you can see the parts change.
2. Set the year of the date field in The_Date_2.
3. Set the week of the date field in The_Date_3.
4. Set the weekday of the date field in The_Date_4.
5. Remove the hours, minutes and second in The_Date_5.
6. Print all of them to see each piece is functioning properly.


DEFINE FILE WEEKLY_SUMM_DETAIL
  THE_DATE_PREP/HYYMDs  = HGETC(8, 'HYYMDs');
  THE_DATE_2/HYYMDs = HSETPT(THE_DATE_PREP, 'year', EDIT(EDIT(WEEK_ATTENDED, '9999')), 8, 'HYYMDs');
  THE_DATE_3/HYYMDs = HSETPT(THE_DATE_2, 'week', EDIT(EDIT(WEEK_ATTENDED, '$$$$$$99')), 8, 'HYYMDs');
  THE_DATE_4/HYYMDs = HSETPT(THE_DATE_3, 'weekday', EDIT(EDIT(WEEK_ATTENDED, '$$$$$$$$$99')), 8, 'HYYMDs');
  THE_DATE_5/HYYMDs = HMIDNT(THE_DATE_4, 8, 'HYYMDs');
END
 
TABLE FILE WEEKLY_SUMM_DETAIL
  PRINT *
            THE_DATE
            THE_DATE_2
            THE_DATE_3
            THE_DATE_4
            THE_DATE_5
WHERE RECORDLIMIT EQ 1000
END


Not pretty, but it works. I'm guessing there's an easier way.