Monday, April 11, 2016

How to get a beginning date and ending date of fiscal year with a current date

Here is a simple peoplecode to get a beginning and ending date of fiscal year with a current date
  
   Local string &sCurrYear = String(Year(%Date));
   Local date &dtLastDay = DateValue("06/30/" | &sCurrYear );
   Local date &dtAsOfDate = DateValue(DateTimeToLocalizedString(%Datetime, "MM/dd/") | &sCurrYear); /* You can use %Date instead */
   Local date dtFirstDay;
   
   If &dtAsOfDate < &dtLastDay Then
      &dtFirstDay = DateValue("7/1/" | String(Value(&sCurrYear) - 1));
      &dtLastDay = DateValue("06/30/" | &sCurrYear); /* for easy to read */
   Else
      &dtFirstDay = DateValue("7/1/" | &sCurrYear);
      &dtLastDay = DateValue("06/30/" | String(Value(&sCurrYear) + 1));
   End-If;

No comments:

Post a Comment