first date of the previous month

J

JIM.H.

Hello,
I know this is the last date of the previous month:
DateSerial(Year(Date()),Month(Date()),0)
How can I get the first date of the previous month?
Thanks,
Jim.
 
R

Rick Brandt

JIM.H. said:
Hello,
I know this is the last date of the previous month:
DateSerial(Year(Date()),Month(Date()),0)
How can I get the first date of the previous month?

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

(obvious if you think about it)
 
J

JIM.H.

so at 01/01/2005, will this give me 12/01/2004? Both year
and month and day correctly? I just want to make sure
about it.
 
D

Douglas J. Steele

Yes it will. Of course, you could easily check this for yourself:

Dim dtmCheck As Date

dtmCheck = #1/1/2005#
Msgbox DateSerial(Year(dtmCheck),Month(dtmCheck)-1,1)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top