Tuesday, October 22, 2013

Get the last day of the month with PeopleCode!

One nice thing to write the function to get "the last day of the month" in PeopleCode is that there is no restriction with the database platform.

Here is the easy how to:

   Local integer &year = Year(%Date);
   Local integer &month = Month(%Date);
   
   /* Get the last day of the month */
   If &month < 12 Then
      &last_day = Date3(&year, &month + 1, 1) - 1;
   Else
      &last_day = Date3(&year + 1, 1, 1) - 1;
   End-If;

No comments:

Post a Comment