Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting the current date

Status
Not open for further replies.

daytona

Programmer
Jul 2, 2002
9
GB
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.

Anyone have any ideas on how to do this?

Cheers - John
 
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.
 
Hi Daytona,

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.

Kevats
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top