#  Other Applications & Softwares  > Access Tables & Databases >  >  How to calculate the year, month & day between two dates

## jordan jordan

Hi All

I want to calculate the usage period for the valve in our company which equal the 
the current date (today) - valve installation date 
the result should be like this  ??year, ?? month ,?? day 
or separate like this 
year: ??
month :??
day : ??
Also I need how to put the equation in the query (access 2007)

Waiting your help

many thanks

Moneer

----------


## alansidman

You have posted in the Access Forum.  Is this an Access question or an Excel Question?

----------


## jordan jordan

it ia an access question

----------


## alansidman

Here is a link with some VBA to create a UDF

http://database.ittoolbox.com/groups...d-days-4835830

----------


## jordan jordan

Iam not good with VBA , i need it as equation in the query

----------


## alansidman

Moneer;
If you had taken the time to read the entire link I provided instead of dismissing it and me with your comment about not being good with VBA, you would have seen that embedded in the page was a non-VBA solution




```
Please Login or Register  to view this content.
```


I took the time to read your entire issue, why didn't you take the time to read my entire solution instead of looking to be spoon fed with a fast and dirty solution.  And if you expect to develop any kind of db in the future using Access, start to learn VBA or you will never get beyond very basic development.

----------


## jordan jordan

Mr. alansidman
Am so sorry , I have not finished reading the entire thread because I found the first and second reply talking about VB , so am not continue the reading and expect it taking about VB solution
and i see you reply "Here is a link with some VBA to create a UDF".
am so sorry again and promise you to start learing thr VB

----------


## jordan jordan

I Try to put the above equation in my query , but some wrong command appear

----------


## alansidman

> I Try to put the above equation in my query , but some wrong command appear



I lost my mind reading licence last week and the moderators took away my crystal ball.  I don't know what this means or how to help you with out more information.

----------


## FDibbins

Alan, I would give you back your crystal ball, but we errr dropped it, and had to send it in for recalibration  :Frown:

----------


## shyamhappy

DateDiff("yyyy", "22/11/2003", "22/11/2013")	would return 10
DateDiff("q", "22/11/2003", "22/11/2013")	would return 40
DateDiff("m", "22/11/2011", "1/1/2012")	would return 2

Syntax if Datediff function is DateDiff( interval, date1, date2, [firstdayofweek], [firstweekofyear] )

Interval	Explanation
yyyy	Year
q	Quarter
m	Month
y	Day of year
d	Day
w	Weekday
ww	Week
h	Hour
n	Minute
s	Second

__________________________________________________________________________________________________________________________
Please click * if this has helped.

“I have not failed. I've just found 10,000 ways that won't work.” 
― Thomas A. Edison

----------


## alansidman

@Ford;
Oh, now I am really lost.  I will have to retake witchcraft 101 all over again.

Alan

----------

