proc main string sDate sDate = LastDayLastMonth() endproc func LastMonth : string integer iDay, iMonth, iYear, iHour, iMin, iSec string sDate ltimeints $LTIME iYear iMonth iDay iHour iMin iSec ;Convert timeval to integer components if iMonth == 1 ;If currently January iMonth = 12 ;Then assign month to December iYear-- ;And decrement year by one else iMonth-- ;Otherwise just move month value back by one endif iDay = 1 ;First day of the month strfmt sDate "%02d%02d" iMonth iYear ;Create MMYYYY string strdelete sDate 2 2 ;Delete first two numbers from year value to get MMYY return sDate endfunc func FirstDayLastMonth : string integer iDay, iMonth, iYear, iHour, iMin, iSec string sDate ltimeints $LTIME iYear iMonth iDay iHour iMin iSec ;Convert timeval to integer components if iMonth == 1 ;If currently January iMonth = 12 ;Then assign month to December iYear-- ;And decrement year by one else iMonth-- ;Otherwise just move month value back by one endif iDay = 1 ;First day of the month strfmt sDate "%02d%02d%d" iMonth iDay iYear ;Create MMDDYYYY string strdelete sDate 4 2 ;Delete first two numbers from year value to get MMDDYY return sDate endfunc func LastDayLastMonth : string integer iDay, iMonth, iYear, iHour, iMin, iSec string sDate long lDate ltimeints $LTIME iYear iMonth iDay iHour iMin iSec ;Convert timeval to integer components iDay = 1 ;First day of the current month intsltime iYear iMonth iDay iHour iMin iSec lDate ;Create time value of first day of current month lDate = lDate - 86400 ;Roll back one day to get last day of month ltimeints lDate iYear iMonth iDay iHour iMin iSec ;Convert timeval to integer components strfmt sDate "%02d%02d%d" iMonth iDay iYear ;Create MMDDYYYY string strdelete sDate 4 2 ;Delete first two numbers from year value to get MMDDYY return sDate endfunc