select the 1st and last date of last month

p0welly

Registered User.
Local time
Today, 08:07
Joined
Aug 26, 2004
Messages
38
Im producing a statement report and the form to generate it allows you to select customer, dates etc, however Id like my StartDate and EndDate text boxes to default to the first and last dates of the previous month.

ie

if you open the account form on any day in march then the start date will be 01/02/06 and the end date will be 28/01/06

any suggestions?

Thanks
 
The first day of the previous month can be derived with:
FirstDay = DateSerial(Year(YourDate), Month(YourDate) -1, 1)
and the last day of the previous month can be derived with:
LastDay = DateSerial(Year(YourDate), Month(YourDate), 0)
using YourDate of course.
 
Works like a charm,

Thanks

:)
 

Users who are viewing this thread

Back
Top Bottom