I'm trying to set the dates of two datawindows to the first and last day of the previous month in their constructor methods. I'm thinking of getting the current date and then performing calculations on it.
Use the Month method to get the current month. Subtract one from it. Since each month begins on the first you have that one pretty easy. For the ending date, build a date string starting at the 31st and loop back until the IsDate method returns true.
I would also think of using the current date and the RelativeDate function. Try this script and see if it works. It uses the first day of the current month.
String ls_date
Date ld_lastdate, ld_firstdate
//Get the first day of the current month - as a string
ls_date = String(Month(Today())) + "/01/" + String(Year(Today()))
//Get day before first day of this month
ld_lastdate = RelativeDate(Date(ls_date), -1)
//Get first day of last month
ld_firstdate = Date(String(Month(ld_lastdate)) + "/01/" + String(Year(ld_lastdate)))
It assumes a short date format "mm/dd/yyyy". Hope it works.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.