Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Question re incrementing Dates by one month

My apologies in advance if part of this question is off topic.

How do I use vba to increment a date by one month ....

and (probably off topic)

What is the usual practise for dating 'monthly' invoices when the date of
previous invoice falls in the range 29th to 31st and the following month has
less days


Regards & TIA


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Question re incrementing Dates by one month

Here is one way that takes the last day of the month if that event happens.
Problem is, eventually it will always settle on the 28th

Dim myDate As Date
Dim newDate As Date
myDate = "March 31 2005"
If Month(DateSerial(Year(myDate), Month(myDate) + 2, 0)) < _
Month(DateSerial(Year(myDate), Month(myDate) + 1, Day(myDate))) Then
newDate = DateSerial(Year(myDate), Month(myDate) + 2, 0)
Else
newDate = DateSerial(Year(myDate), Month(myDate) + 1, Day(myDate))
End If
MsgBox newDate


--
HTH

Bob Phillips

"SA3214 @Eclipse.co.uk" <sa3214<No Spam wrote in message
...
My apologies in advance if part of this question is off topic.

How do I use vba to increment a date by one month ....

and (probably off topic)

What is the usual practise for dating 'monthly' invoices when the date of
previous invoice falls in the range 29th to 31st and the following month

has
less days


Regards & TIA




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Question re incrementing Dates by one month

On Fri, 6 May 2005 22:11:59 +0100, "SA3214" <sa3214<No
wrote:

My apologies in advance if part of this question is off topic.

How do I use vba to increment a date by one month ....

and (probably off topic)

What is the usual practise for dating 'monthly' invoices when the date of
previous invoice falls in the range 29th to 31st and the following month has
less days


Regards & TIA


I believe the usual practice is to date the invoice as of the last day of the
month.

In order to do this, you need to always refer back to a "seed date", or else,
when adjusting to the end of the month, you'd have no way of knowing what the
correct day should be for the following month.

In VBA, the DateAdd function will adjust to the proper end of month date.



So something like this should give you some ideas:

Sub IncrMonth()
Const SeedDt As Date = "31 Jan 2004"
Dim NumMnths As Double

For NumMnths = 0 To 12
MsgBox (NumMnths & " months since " & SeedDt & _
" is " & DateAdd("m", NumMnths, SeedDt))
Next NumMnths

End Sub

--ron
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Incrementing dates in the format MMM-YY kmewing Excel Discussion (Misc queries) 3 October 19th 07 06:03 PM
Repeating/incrementing dates 35039 times Daiv Excel Discussion (Misc queries) 5 January 4th 07 09:54 PM
Dates Formatting Question - What if you do not know month and/or d elfmajesty Excel Discussion (Misc queries) 4 October 12th 06 08:37 PM
Fill column with dates of month depending on month in A1 [email protected] Excel Programming 7 March 11th 05 12:41 AM
Incrementing dates by one hour returns bad result jennifer Excel Programming 0 November 19th 03 06:45 PM


All times are GMT +1. The time now is 02:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"