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.
current date, calculate one moth back intit and end date
-
- PlatinumLounger
- Posts: 4266
- Joined: 26 Apr 2010, 17:36
-
- 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)
DateSerial(Year(Date), Month(Date) - 1, 1)
Last day of previous month:
Date - Day(Date)
-
- Administrator
- Posts: 77254
- 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)
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)
Regards,
Hans
Hans
-
- PlatinumLounger
- Posts: 4266
- Joined: 26 Apr 2010, 17:36
Re: current date, calculate one moth back intit and end date
tks for sugestion!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)


-
- PlatinumLounger
- Posts: 4266
- Joined: 26 Apr 2010, 17:36
Re: current date, calculate one moth back intit and end date
Tks!mbarron wrote:First day of previous month:
DateSerial(Year(Date), Month(Date) - 1, 1)
Last day of previous month:
Date - Day(Date)
