473,685 Members | 3,248 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8762
Look up Dateadd in help
You will use something like DateAdd("m", 1, "31-Jan-95") or DateAdd("m", 1,
"[youdatefieldnam e]")
HTH
David B

John Baker <Ba******@Veriz on.net> wrote in message
news:qg******** *************** *********@4ax.c om...
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******@Veriz on.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******@Veriz on.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******@Veriz on.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.goo gle.com:
John Baker <Ba******@Veriz on.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******@Veriz on.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******* ************@13 0.133.1.4>...
lo************@ hotmail.com (Brian) wrote in
news:f3******** *************** ***@posting.goo gle.com:
John Baker <Ba******@Veriz on.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
3934
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" message. Help much appreciated Jim var m=new Array(13);var n=new Date()
4
2010
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 to each day of the week. I want to have the Month and Day after the day of the week. My problem is during transition weeks, from one month to the next, that I cannot figure out how to have it know to start over with day 1 on the next month.
2
21074
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
6781
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 that I can get an actual count of the accounts that were closed during the month. I believe that the calculation involves Between(DateSerial(year(Date() etc but I can't figure it out. Thanks, -- Message posted via http://www.accessmonster.com
1
1645
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
1163
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"))); DDCycle.Items.Add(new ListItem(DateTime.Now.ToString("MMMM"), DateTime.Now.ToString("M/yy"))); I want to add below value if next month is about start in 5 or less days : DDCycle.Items.Add(new ListItem(DateTime.Now.AddMonths(1).ToString("MMMM"),...
4
3664
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 dumbed down answer is greatly appreciated, thank you all so much.
9
2737
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 it by correct ascending orders not sorting the first digits only.
3
2886
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 Subject = GridBulletins.Rows.Cells.Value; var Bulletin = GridBulletins.Rows.Cells.Value;
0
8569
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8758
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7584
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6431
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5789
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4299
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4521
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2935
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2196
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.