Obtain the last day of a monthTag(s): Powerscript


Take a date, increment the month, change the day for "01" then decrement by 1.
int li_retdays, li_month, li_year

li_month = Month(ad_date)
li_year = year(ad_date)

IF li_month < 12 THEN
   li_month ++
ELSE
   li_month = 1
   li_year ++
END IF

// build a new date
ld_newdate = date(li_year),li_month,1)
// extract the last day of the previous month
ld_previousmonthlastday = Day(RealtiveDate(ld_newdate, -1))

blog comments powered by Disqus