473,616 Members | 2,973 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 8761
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
2004
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
21072
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
6776
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
1643
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
1161
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
2733
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
2881
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
8203
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...
0
8146
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8647
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8592
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6097
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
5550
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
4141
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2579
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

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.