## current date, calculate one moth back intit and end date

sal21
PlatinumLounger
Posts: 4452
Joined: 26 Apr 2010, 17:36

### current date, calculate one moth back intit and end date

I need to a function to calculte the first and last date of one month back based current date...example:

now is 13/10/2010

calculate the first day and the last day of one month back, in this case is september.

first_day =01/09/2010
last_day=30/09/2010

note:
in vb6 classic
tks.

mbarron
2StarLounger
Posts: 112
Joined: 25 Jan 2010, 20:19

### Re: current date, calculate one moth back intit and end date

First day of previous month:
DateSerial(Year(Date), Month(Date) - 1, 1)

Last day of previous month:
Date - Day(Date)

HansV
Posts: 79113
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

### Re: current date, calculate one moth back intit and end date

Let's say that your date is stored in a variable MyDate.

The first of the previous month is DateSerial(Year(MyDate), Month(MyDate) - 1, 1)
The last of the previous month is DateSerial(Year(MyDate), Month(MyDate), 0)
Best wishes,
Hans

sal21
PlatinumLounger
Posts: 4452
Joined: 26 Apr 2010, 17:36

### Re: current date, calculate one moth back intit and end date

HansV wrote:Let's say that your date is stored in a variable MyDate.

The first of the previous month is DateSerial(Year(MyDate), Month(MyDate) - 1, 1)
The last of the previous month is DateSerial(Year(MyDate), Month(MyDate), 0)
tks for sugestion!

sal21
PlatinumLounger
Posts: 4452
Joined: 26 Apr 2010, 17:36

### Re: current date, calculate one moth back intit and end date

mbarron wrote:First day of previous month:
DateSerial(Year(Date), Month(Date) - 1, 1)

Last day of previous month:
Date - Day(Date)
Tks!