472,127 Members | 2,085 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

Adding one month to a date -- no as easy as it appers!

HI:

I have a date, and am trying to do something that SHOULD be very simple -- but finding a
problem. Assume the date is 01/01/03. I wish to make the date 02/01/03, and then next
month 03/01/03 and so on. In other words, I want to add one to the month and reset the
date. However, adding a given number of days (say 30) does not work because of the
variation in the number of days in a month.

Is there a simple way to increment dates by a month? If so what is it?

Thanks in advance.

regards

John Baker
Nov 12 '05 #1
7 8648
Look up Dateadd in help
You will use something like DateAdd("m", 1, "31-Jan-95") or DateAdd("m", 1,
"[youdatefieldname]")
HTH
David B

John Baker <Ba******@Verizon.net> wrote in message
news:qg********************************@4ax.com...
HI:

I have a date, and am trying to do something that SHOULD be very simple -- but finding a problem. Assume the date is 01/01/03. I wish to make the date 02/01/03, and then next month 03/01/03 and so on. In other words, I want to add one to the month and reset the date. However, adding a given number of days (say 30) does not work because of the variation in the number of days in a month.

Is there a simple way to increment dates by a month? If so what is it?

Thanks in advance.

regards

John Baker


Nov 12 '05 #2
Look at dateadd in the help, as in:

dateadd("m", 1, #1/1/04#)

Tom

John Baker <Ba******@Verizon.net> wrote in message news:<qg********************************@4ax.com>. ..
HI:

I have a date, and am trying to do something that SHOULD be very simple -- but finding a
problem. Assume the date is 01/01/03. I wish to make the date 02/01/03, and then next
month 03/01/03 and so on. In other words, I want to add one to the month and reset the
date. However, adding a given number of days (say 30) does not work because of the
variation in the number of days in a month.

Is there a simple way to increment dates by a month? If so what is it?

Thanks in advance.

regards

John Baker

Nov 12 '05 #3
Thanks..
I guess it IS as easy as it appears!!!!

Regards

John Baker

John Baker <Ba******@Verizon.net> wrote:
HI:

I have a date, and am trying to do something that SHOULD be very simple -- but finding a
problem. Assume the date is 01/01/03. I wish to make the date 02/01/03, and then next
month 03/01/03 and so on. In other words, I want to add one to the month and reset the
date. However, adding a given number of days (say 30) does not work because of the
variation in the number of days in a month.

Is there a simple way to increment dates by a month? If so what is it?

Thanks in advance.

regards

John Baker


Nov 12 '05 #4
John Baker <Ba******@Verizon.net> wrote in message news:<qg********************************@4ax.com>. ..
HI:

I have a date, and am trying to do something that SHOULD be very simple -- but finding a
problem. Assume the date is 01/01/03. I wish to make the date 02/01/03, and then next
month 03/01/03 and so on. In other words, I want to add one to the month and reset the
date. However, adding a given number of days (say 30) does not work because of the
variation in the number of days in a month.

Is there a simple way to increment dates by a month? If so what is it?

Thanks in advance.

regards
Not simple but here is what you do.

Break the date down using Month, Day and Year functions into (1,1 and
2003 all integers)
Increment the month by one (2,1 and 2003)
Then convert into strings and concatenate them back into a string
inserting the "/" separator as necessary. ("1/01/2003")
Use DateValue function to convert back into a date value.

John Baker

Nov 12 '05 #5
lo************@hotmail.com (Brian) wrote in
news:f3**************************@posting.google.c om:
John Baker <Ba******@Verizon.net> wrote in message
news:<qg********************************@4ax.com>. ..
HI:

I have a date, and am trying to do something that SHOULD be very simple
-- but finding a problem. Assume the date is 01/01/03. I wish to make
the date 02/01/03, and then next month 03/01/03 and so on. In other
words, I want to add one to the month and reset the date. However,
adding a given number of days (say 30) does not work because of the
variation in the number of days in a month.

Is there a simple way to increment dates by a month? If so what is it?

Thanks in advance.

regards


Not simple but here is what you do.

Break the date down using Month, Day and Year functions into (1,1 and
2003 all integers)
Increment the month by one (2,1 and 2003)
Then convert into strings and concatenate them back into a string
inserting the "/" separator as necessary. ("1/01/2003")
Use DateValue function to convert back into a date value.


Ouch!

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #6
John Baker <Ba******@Verizon.net> wrote in message news:<qg********************************@4ax.com>. ..
HI:

I have a date, and am trying to do something that SHOULD be very simple -- but finding a
problem. Assume the date is 01/01/03. I wish to make the date 02/01/03, and then next
month 03/01/03 and so on. In other words, I want to add one to the month and reset the
date. However, adding a given number of days (say 30) does not work because of the
variation in the number of days in a month.

Is there a simple way to increment dates by a month? If so what is it?

Thanks in advance.

regards

John Baker


If memory serves, you should be able to use the DateAdd function and
simply do something like:

dim your_date as date
dim next_date as date

your_date = CDate("1/1/03")
next_date = DateAdd("m", 1, your_date)

Cheers,
Steve Cummings
Nov 12 '05 #7
Lyle Fairfield <Mi************@Invalid.Com> wrote in message news:<Xn*******************@130.133.1.4>...
lo************@hotmail.com (Brian) wrote in
news:f3**************************@posting.google.c om:
John Baker <Ba******@Verizon.net> wrote in message
news:<qg********************************@4ax.com>. ..
HI:

I have a date, and am trying to do something that SHOULD be very simple
-- but finding a problem. Assume the date is 01/01/03. I wish to make
the date 02/01/03, and then next month 03/01/03 and so on. In other
words, I want to add one to the month and reset the date. However,
adding a given number of days (say 30) does not work because of the
variation in the number of days in a month.

Is there a simple way to increment dates by a month? If so what is it?

Thanks in advance.

regards


Not simple but here is what you do.

Break the date down using Month, Day and Year functions into (1,1 and
2003 all integers)
Increment the month by one (2,1 and 2003)
Then convert into strings and concatenate them back into a string
inserting the "/" separator as necessary. ("1/01/2003")
Use DateValue function to convert back into a date value.


Ouch!


Thanks. I found the other responses very educational.
Nov 12 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Jim | last post: by
4 posts views Thread by Treetop | last post: by
2 posts views Thread by smcgrath via AccessMonster.com | last post: by
ddtpmyra
9 posts views Thread by ddtpmyra | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.