IncredibleVolk
Technical User
I stoled some of this from other scripts on this site. This starts off giving me the first and last day of the month for the previous month. I was wondering if anyone knows how I loop this so it would decrement the month each time through.
January -08
December - 07
November - 07
etc...
proc Main
string sDate,sDate2
integer iYear,iMonth,iDay,iDay2,iHour,iMin,iSec
integer Loops
integer iWeekday,iDayYear,iLeapYear
long Timeval
txflush
pause 1
rxflush
pause 1
for Loops = 0 upto 1
**FIRST DAY OF THE MONTH**
ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
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
strdelete sDate 6 2
usermsg "FIRST DATE %s" sDate
******LAST DAY OF THE MONTH**
if iDay2 <= 31
switch iMonth
case 1 ;January
case 3 ;March
case 5 ;May
case 7 ;July
case 8 ;August
case 10 ;October
case 12 ;December
iDay2 = 31 ;31 Days
endcase
case 4 ;April
case 5 ;May
case 6 ;June
case 9 ;September
case 11 ;November
iDay2 = 30 ;30 days
endcase
case 2 ;February
intsltime iYear iMonth iDay2 iHour iMin iSec TimeVal ;Convert to a long time value
ltimemisc TimeVal iWeekday iDayYear iLeapYear ;Get leap year value
if iLeapYear == 1 ;If leap year
iDay2 = 29 ;Set day to 29
else
iDay2 = 28
endif
endcase
endswitch
endif
strfmt sDate2 "%02d-%02d-%d" iMonth iDay2 iYear
strdelete sDate2 6 2
usermsg "SECOND DATE %s" sDate2
statmsg "Month %d" Loops
loopfor
exitfor
endfor
endproc
January -08
December - 07
November - 07
etc...
proc Main
string sDate,sDate2
integer iYear,iMonth,iDay,iDay2,iHour,iMin,iSec
integer Loops
integer iWeekday,iDayYear,iLeapYear
long Timeval
txflush
pause 1
rxflush
pause 1
for Loops = 0 upto 1
**FIRST DAY OF THE MONTH**
ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
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
strdelete sDate 6 2
usermsg "FIRST DATE %s" sDate
******LAST DAY OF THE MONTH**
if iDay2 <= 31
switch iMonth
case 1 ;January
case 3 ;March
case 5 ;May
case 7 ;July
case 8 ;August
case 10 ;October
case 12 ;December
iDay2 = 31 ;31 Days
endcase
case 4 ;April
case 5 ;May
case 6 ;June
case 9 ;September
case 11 ;November
iDay2 = 30 ;30 days
endcase
case 2 ;February
intsltime iYear iMonth iDay2 iHour iMin iSec TimeVal ;Convert to a long time value
ltimemisc TimeVal iWeekday iDayYear iLeapYear ;Get leap year value
if iLeapYear == 1 ;If leap year
iDay2 = 29 ;Set day to 29
else
iDay2 = 28
endif
endcase
endswitch
endif
strfmt sDate2 "%02d-%02d-%d" iMonth iDay2 iYear
strdelete sDate2 6 2
usermsg "SECOND DATE %s" sDate2
statmsg "Month %d" Loops
loopfor
exitfor
endfor
endproc