It's an easy fix...

0001     today = 16528   ;*April Fools Day
0002     mth = OCONV(today, 'DM')
0003     yr = OCONV(today, 'DY')
0004     first_of_month = ICONV(mth:'-1-':yr, 'D')
0005     day_of_week = OCONV(first_of_month, 'DW')
0006     IF day_of_week = 1 THEN
0007         first_monday = today
0008     END ELSE
0009         first_monday = first_of_month + (8-day_of_week)
0010     END
0011     CRT OCONV(first_monday, 'D'):' is the 1st Monday of this month.'


On Mon, Jan 7, 2013 at 3:59 PM, Kevin Powick <[email protected]> wrote:

>
>
> On Monday, 7 January 2013 10:46:00 UTC-5, Daniel Klein wrote:
>
>>
>> 0001     today = DATE()
>> 0002     mth = OCONV(today, 'DM')
>> 0003     yr = OCONV(today, 'DY')
>> 0004     first_of_month = ICONV(mth:'-1-':yr, 'D')
>> 0005     day_of_week = OCONV(first_of_month, 'DW')
>> 0006     first_monday = first_of_month + (8-day_of_week)
>> 0007     CRT OCONV(first_monday, 'D'):' is the 1st Monday of this month.'
>>
>>
> That code actually doesn't work in all cases.  For example, try April 2013
>
> The following should give the 1st through 4th Mondays for any given month
> and year:
>
> TODAY = DATE()
> YEAR  = OCONV(TODAY,'DY')
> MONTH = OCONV(TODAY,'DMA')
>
> FIRST.OF.MONTH = ICONV('1':MONTH:YEAR,'D4')
> DAY.OF.WEEK    = OCONV(FIRST.OF.MONTH,'DW')
>
> IF DAY.OF.WEEK = 1 THEN
>    FIRST.MONDAY = FIRST.OF.MONTH
> END ELSE
>    FIRST.MONDAY = FIRST.OF.MONTH + (8 - DAY.OF.WEEK)
> END
>
> FOURTH.MONDAY = FIRST.MONDAY + 21
>
> FOR MONDAY = FIRST.MONDAY TO FOURTH.MONDAY STEP 7
>    CRT 'MONDAY = ':OCONV(MONDAY,'D2')
> NEXT MONDAY
>
> --
> Kevin Powick
>
> --
> --
> IMPORTANT: T24/Globus posts are no longer accepted on this forum.
>
> To post, send email to [email protected]
> To unsubscribe, send email to [email protected]
> For more options, visit this group at
> http://groups.google.com/group/jBASE?hl=en
>
>
>
>

-- 
-- 
IMPORTANT: T24/Globus posts are no longer accepted on this forum.

To post, send email to [email protected]
To unsubscribe, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/jBASE?hl=en



Reply via email to