Datedif Function in access

D

Daoud Fakhry

Hi all, I know how to use datedif function in excel, but I don't know if this
function even exists in Access or not. I have the following formula in excel
and would like to use this in access as well. Is there any master to help me.
I appreciate your cooperation in advance.

My formula is:
=(DATEDIF(Hiredate,EffectiveDate,"ym")+1)/12

I count the number of months in excel by the above formula by providing two
different dates, where Hire date is an employee's hire date and Effective
Date is a date of the effective date of the last bonuses paid.

Thanks,
Daoud
 
D

Douglas J. Steele

Interesting. I find no reference to DateDif in the Help for Excel 2003,
although the Object Browser indicates that the same DateDiff function as in
Access exists. However, the DateDiff function has a different syntax than
what you're showing:

DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])

where interval can only take the following values:
yyyy (Year), q (Quarter), m (Month), y (Day of year), d (Day), w
(Weekday), ww (Week), h (Hour), n (Minute), s (Second)


See whether

=DateDiff("m", Hiredate, EffectiveDate) or =DateDiff("m", Hiredate,
EffectiveDate) + 1

gives you what you want.
 
O

Ofer Cohen

In Access it called - DateDiff
Check help on the different options

This
=(DATEDIF(Hiredate,EffectiveDate,"ym")+1)/12

will be
=(DateDiff("m",Hiredate,EffectiveDate)+1) / 12
 
M

Maurice

Hi Daoud,

You can use the DateDiff. Try something like this:

(DateDiff("m";[date1];[date2])+1)/12

Access has the interval stated in the beginning of the function. Furthermore
the interval is doing the math by Y, M, D etc. Combinations like Excel uses
don't work in Access. So you just might have to tune your query a little to
get the right results.

hth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top