473,378 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 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 8749
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jim | last post by:
I have been using the javascript below on a web page since last August to show the "Site updated" month minus a month, which has been very successful, but January is showing a "undefined 2004"...
4
by: Treetop | last post by:
I have a script for my church that we use for the weekly events. I currently have it as week of Feb 1, 2003 at the top, then list Sun - Sat below the date. I have been asked to put the date next...
2
by: markryde | last post by:
Hello, I am trying to add the current date to a file name in python script like thus: import os import sys import rpm import time import datetime
2
by: smcgrath via AccessMonster.com | last post by:
I have a table listing accounts with a closed date - our Trial balance drops the account after 7 days but our database keeps the record forever - How do I calculate the end of month less 7 days so...
1
by: ganeshpillai | last post by:
I want to write a progeam that displays date in the following format (dd/mm/yyyy) 09/06/2007 or 9/6/2007 .
2
parshupooja
by: parshupooja | last post by:
Hey, I have dropdownlist where I am adding 2 values: DDCycle.Items.Add(new ListItem(DateTime.Now.AddMonths(-1).ToString("MMMM"), DateTime.Now.AddMonths(-1).ToString("M/yy")));...
4
by: mattgray89 | last post by:
I am new to Access and trying to wrap my head around VBA. I need to first add 17 months to the field "1stQualLastSat" and to have the output date be at the end of that month. Is this possible? A...
9
ddtpmyra
by: ddtpmyra | last post by:
Im using PHP report and I convert the month date into numbers but when I generate and publish it now displaying like this... 1 10 11 2 3 4 5 6 and so forth. How can I make it happen to sor...
3
by: vertigo262 | last post by:
this one should be pretty simple. All I want to do is formatdate in this format. Saturday, September 25, 2010 12:00 am function getRecordInfo(oLink, iIndex) { var...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.