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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|