Access VBA Get dates for last month

Murray Brown
Murray Brown used Ask the Experts™
Hi.  If the following code finds the start and end of last year, what similar code doI use to find the start and end of last month

txtStartDate = DateSerial(Year(Date) - 1, 1, 1)
txtEndDate = DateSerial(Year(Date) - 1, 12, 31)
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hardware Tester and Debugger
Hi there! :)

Try these and see if they return the values you want.

FirstDayofPreviousMonth = DateSerial(Year(Date), Month(Date) - 1, 1)

Open in new window

LastDayOfPreviousMonth = DateSerial(Year(Date()), Month(Date()),0)

Open in new window

Daniel PineaultPresident / Owner CARDA Consultants Inc.
Distinguished Expert 2018

Murray Developer


thanks very much
NoahHardware Tester and Debugger

You're welcome! Glad I was of help :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial