A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Select 1st date of subsequent month based



 
 
Thread Tools Display Modes
  #1  
Old July 9th, 2009, 04:38 PM posted to microsoft.public.access
G2[_2_]
external usenet poster
 
Posts: 4
Default Select 1st date of subsequent month based

Hi,

I'm trying to build a calculated field in an Access query to do the
following:

Select the 1st date of the month following whatever month the "Rate
Effective Date" is in.
For example:

If Rate Effective Date = 7/9/2009, the field will return 8/1/2009.
If Rate Effective Date = 12/31/2009, the field will return 1/1/2010.

It's probably a simple line of sql code or easy to build with the
function builder, but I haven't worked in Access for awhile and google
has fallen short.

Thanks!!!
  #2  
Old July 9th, 2009, 04:58 PM posted to microsoft.public.access
Allen Browne
external usenet poster
 
Posts: 11,706
Default Select 1st date of subsequent month based

Try:
DateAdd("m", 1, [Rate Effective Date] - Day([Rate Effective Date]) + 1)

Subtracting the day of the month yields the last day of the previous month.
Adding 1 is the first of the current month.
The DateAdd() then adds 1 month.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"G2" wrote in message
...
Hi,

I'm trying to build a calculated field in an Access query to do the
following:

Select the 1st date of the month following whatever month the "Rate
Effective Date" is in.
For example:

If Rate Effective Date = 7/9/2009, the field will return 8/1/2009.
If Rate Effective Date = 12/31/2009, the field will return 1/1/2010.

It's probably a simple line of sql code or easy to build with the
function builder, but I haven't worked in Access for awhile and google
has fallen short.

Thanks!!!

  #3  
Old July 9th, 2009, 05:01 PM posted to microsoft.public.access
Jerry Whittle
external usenet poster
 
Posts: 4,732
Default Select 1st date of subsequent month based

Debug.Print DateAdd("m",1,#7/9/2009#)-Day(#7/9/2009#)+1 = 8/1/2009

In a query:

TheNextMonth: DateAdd("m",1,[Rate Effective Date])-Day([Rate Effective
Date])+1
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

"G2" wrote:

Hi,

I'm trying to build a calculated field in an Access query to do the
following:

Select the 1st date of the month following whatever month the "Rate
Effective Date" is in.
For example:

If Rate Effective Date = 7/9/2009, the field will return 8/1/2009.
If Rate Effective Date = 12/31/2009, the field will return 1/1/2010.

It's probably a simple line of sql code or easy to build with the
function builder, but I haven't worked in Access for awhile and google
has fallen short.

Thanks!!!

  #4  
Old July 9th, 2009, 06:21 PM posted to microsoft.public.access
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Select 1st date of subsequent month based

On Thu, 9 Jul 2009 08:38:10 -0700 (PDT), G2 wrote:

Hi,

I'm trying to build a calculated field in an Access query to do the
following:

Select the 1st date of the month following whatever month the "Rate
Effective Date" is in.
For example:

If Rate Effective Date = 7/9/2009, the field will return 8/1/2009.
If Rate Effective Date = 12/31/2009, the field will return 1/1/2010.

It's probably a simple line of sql code or easy to build with the
function builder, but I haven't worked in Access for awhile and google
has fallen short.

Thanks!!!


DateSerial(Year([Rate Effective Date]), Month([Rate Effective Date]) + 1, 1)

will work (as will the DateAdd suggestions). Just in case you need the last
day of the current month instead of the first day of the next month, use 0
instead of 1 for the last argument.

--

John W. Vinson [MVP]
  #5  
Old July 15th, 2009, 02:53 PM posted to microsoft.public.access
G2[_2_]
external usenet poster
 
Posts: 4
Default Select 1st date of subsequent month based

Excellent, thank you,that would do it!
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


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


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