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 » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Get number of months between two dates



 
 
Thread Tools Display Modes
  #1  
Old January 6th, 2009, 04:21 PM posted to microsoft.public.access.forms
Abe Katz
external usenet poster
 
Posts: 43
Default Get number of months between two dates

Hello everybody and happy New Year!

I need to get the number of months between current date and Invoice date, so
I did the following
DatePart("m",[CurDate])-DatePart("m",[InvDate])
but this only works till January.
Is there a way to get the correct number? i.e. CurDate 01/06/09, InvDate
08/15/08 = 5
I tried combining with the year, but it doesn't work.
Format([CurDate],"yymm")-Format([InvDate],"yymm")

Thank you in advance


  #2  
Old January 6th, 2009, 04:28 PM posted to microsoft.public.access.forms
RonaldoOneNil
external usenet poster
 
Posts: 345
Default Get number of months between two dates

Use DateDiff("m",[CurDate],[InvDate])

"Abe Katz" wrote:

Hello everybody and happy New Year!

I need to get the number of months between current date and Invoice date, so
I did the following
DatePart("m",[CurDate])-DatePart("m",[InvDate])
but this only works till January.
Is there a way to get the correct number? i.e. CurDate 01/06/09, InvDate
08/15/08 = 5
I tried combining with the year, but it doesn't work.
Format([CurDate],"yymm")-Format([InvDate],"yymm")

Thank you in advance



  #3  
Old January 6th, 2009, 05:07 PM posted to microsoft.public.access.forms
Dale Fye
external usenet poster
 
Posts: 2,651
Default Get number of months between two dates

DateDiff is probably the best bet, although it will count the number of month
transitions between two dates.

datediff("m", #12/31/08#, #1/1/09#) = 1, even though there is only 1 days
difference between the two dates.

From your example it looks like you want to report partial months as months,
so this should work.
--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



"Abe Katz" wrote:

Hello everybody and happy New Year!

I need to get the number of months between current date and Invoice date, so
I did the following
DatePart("m",[CurDate])-DatePart("m",[InvDate])
but this only works till January.
Is there a way to get the correct number? i.e. CurDate 01/06/09, InvDate
08/15/08 = 5
I tried combining with the year, but it doesn't work.
Format([CurDate],"yymm")-Format([InvDate],"yymm")

Thank you in advance



  #4  
Old January 6th, 2009, 07:17 PM posted to microsoft.public.access.forms
Abe Katz
external usenet poster
 
Posts: 43
Default Get number of months between two dates

Thank you very much!

"RonaldoOneNil" wrote in message
...
Use DateDiff("m",[CurDate],[InvDate])

"Abe Katz" wrote:

Hello everybody and happy New Year!

I need to get the number of months between current date and Invoice date,
so
I did the following
DatePart("m",[CurDate])-DatePart("m",[InvDate])
but this only works till January.
Is there a way to get the correct number? i.e. CurDate 01/06/09, InvDate
08/15/08 = 5
I tried combining with the year, but it doesn't work.
Format([CurDate],"yymm")-Format([InvDate],"yymm")

Thank you in advance





 




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 03:54 PM.


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