Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Number of Months

Status
Not open for further replies.

tomk01

ISP
Oct 18, 2004
69
US
I need to know how long an employee has worked at a company. I know the hire date. what is the right formula to produce only the number of months? I was thinking:

select (now - hiredate) as MonthsOfService
 
tomk01,

Try DateDiff Function
Code:
NbrMos = DateDiff("m", YourDate, Date())


Skip,

[glasses] [red]Be advised:[/red] Researchers have found another Descartes trueism, "Cogito ergo spud."
"I think; therefore, I YAM!
[tongue]
 
but recognize that DateDiff returns the number of interval bioundaries traversed in the interval, So:


Code:
? DateDiff("m", #11/30/04#, #12/1/04#)
 1 


? DateDiff("m", #11/1/04#, #12/31/04#)
 1 
[code]

Which may (or may NOT) be suitable to the application.





MichaelRed
 


The most EXACT method is to calculate the number of DAYS, since a MONTH is ambiguous, You can convert days to months by the product of DAYS and ([12 mo per yr] / [365.25 days per yr])

Skip,

[glasses] [red]Be advised:[/red] Researchers have found another Descartes trueism, "Cogito ergo spud."
"I think; therefore, I YAM!
[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top