Here’s a sample of RPGLE source that gets Day-of-week with a division and remainder
This one packages the same logic it into a sub-procedure and returns day name.
and one more
if Given_date is NOT a date field
if Given_date is a date field
both yield 0=Mon, 1=Tue, … , 6=Sun
Why %abs of %rem ????
.. not that it’s going to give the wrong value,
just how can %rem ever return a negative number?
The difference between both dates may be negative and %rem may results in negative number
“%REM returns the remainder that results from dividing operands n by m. The two operands must be numeric values with zero decimal positions. If either operand is a packed, zoned, or binary numeric value, the result is packed numeric. If either operand is an integer numeric value, the result is integer. Otherwise, the result is unsigned numeric. Float numeric operands are not allowed. <b>The result has the same sign as the dividend.</b>”
To work, ‘0001-01-01′ must be Monday right?
thanks for ur help!!! I have used the remainder logic and that works fine!!!