Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

RPGLE and dates

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • RPGLE and dates

    Assuming you know how to extract a year, a month, or a day from a given date, then the first of month should be a no brainer since it's always 1. To get the end of the month for a given month, subtract one day from the month following the month of the date you're interested in.

  • #2
    RPGLE and dates

    Ok, so we all have bad days and ask stupid questions. Attached code is not fancy but does what I need. Suggestions on code improvement are welcomed. Larry Swain
    Code

    Comment


    • #3
      RPGLE and dates

      lswain wrote: > > Attached code is not fancy but does what I need. > Suggestions on code improvement are welcomed. *DATE gives the jobdate; if you want the system date, it's better to use the TIME opcode or %DATE. Eval WorkDate = %Date() If you change BEGDATE and ENDDATE to be 7 instead of 8, you can just do Eval BegDate7 = BegDate Or just do the overlays of Beg_Year and Beg_Days directly onto BegDate. (Not sure what you need the Years and Days values for.) If you want to avoid the explicit overlay on your date field, and have it work with any date format, you could get the first day of the month like this: Eval WorkDate = %Date() Eval Days = %SubDt(WorkDate : *days) Eval WorkDate = WorkDate - %Days(days + 1) Aside: The closer we get to 2039, the less wise it seems to use a 2-digit-year format *YMD, instead of a 4-digit-year format like *ISO.

      Comment


      • #4
        RPGLE and dates

        Need to compute beginning of month and end of month based on current date. Also need to be able to use variable and backup 3 or 4 months from current date. Any assistance is appreciated. Thanks Larry Swain larry.swain@robins.af.mil

        Comment


        • #5
          RPGLE and dates

          Don't you want: Eval WorkDate = WorkDate - %Days(days - 1)

          Comment


          • #6
            RPGLE and dates

            SamL wrote: > > Don't you want: > > Eval WorkDate = WorkDate - %Days(days - 1) Ackkk! Yes, you are right, sorry.

            Comment

            Working...
            X