× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 6/12/2012 1:52 PM, Dennis wrote:
Oops. . . in my haste to get to work -- because, don't we all love
ourjobs that much? -- I stopped the changes too soon. I will leave
completion as an exercise for no extra points.

This is the only way I can think of to do it without work variables.

if %subdt(MyNewDateField: *Days)>= 16 ; // set day to 16
MyNewDateField -= %days( %subdt(MyNewDateField: *Days) - 16 ) ;
else ; //<= 15 ; set day to 01
MyNewDateField -= %days( %subdt(MyNewDateField: *Days) - 01 ) ;
endif ;

But, gagorama, I should be awarded negative points for even typing this. Not only does it do the costly %subdt twice, it has the same complex expression three times in the code, maximizing the potential for maintenance errors. Hoping there's a better solution to Dennis' challenge.

Here's a way of using the work variable twice, to further simplify the code by having only one statement where the %days is subtracted.

Days = %subdt(MyNewDateField: *Days);
if Days >= 16 ; // set day to 16, eg 2012/06/27
Days -= 16; // by subtracting this many days, eg 11
else; // set day to 1, eg 2012/06/09
Days -= 1; // by subtracting this many days, eg 8
endif;
MyNewDateField -= %days( Days );

I'm a fan of using work variables and extra statements to simplify code. I'm a bit uneasy about using the vague "Days" for two purposes, though. Maybe two work variables, "DayNbr" and "DaysToSubtract", would be better.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.