How to count months after finished last year & count days after last finished month?

mraccess101

Registered User.
Local time
Yesterday, 19:47
Joined
Feb 11, 2013
Messages
21
How to count months after finished last year & count days after last finished month?

Recently I moved from using Excel to Access to track my data, and I love it. But I have some difficulties to translate one function that I very often have used in Excel, namely the function "DATEDIF". After some research to find how to do this is Access I found the function "DATEDIFF", with an extra "F" in comparison with Excel. But the function "DATEDIFF" in Access does not the same thing as the function "DATEDIF" in Excel. The difference is that the "DATEDIF" in Excel can count the days after the last completed month and/or count the months after the last completed year.

This is how I used the function in Excel.

=DATEDIF(B2,NOW(),"y")&" Years, "&DATEDIF(B2,NOW(),"ym")&" month, and "&DATEDIF(B2,NOW(),"md")&" days"

Screen_Shot_2013_04_14_at_03_13_48.png


"YM" counts the month(s) after the last finished year
"MY" counts the days(s) after the last finished month

This video shows in more detail how the function works.
http://www.youtube.com/watch?v=F9dz30QkL7g



And this is how I try to use the function in Access.

Query

Screen_Shot_2013_04_14_at_03_04_56.png


Result

Screen_Shot_2013_04_14_at_03_05_35.png



Sadly, the function doesn't allow me to calculate exact the years, months and days like Excel does.


This function I used to track registration time was for me very helpful, but unfortunately I still not have find a way to do the same in Access. I hope someone have a solution to have the same result as I had in Excel.

Thanks in advance.

Please forgive me for my grammatical errors, English is not my native language.
 
Re: How to count months after finished last year & count days after last finished mon

Have a look at this custom function. You would copy the code into a general module in your application, the call it in queries or code when necessary.
 
Re: How to count months after finished last year & count days after last finished mon

Have a look at this custom function. You would copy the code into a general module in your application, the call it in queries or code when necessary.

Would you please explain me what a general module is? I recently started using Access, therefore I'm not experienced.
 
Re: How to count months after finished last year & count days after last finished mon

After some self research I managed to find out how to make a module and use it in a query. I also managed to solve my problem. Thank you for helping
 

Users who are viewing this thread

Back
Top Bottom