If {Months_Of_Service.HR_JOB_
DateDiff("d",{Months_Of_Se
Main Topics
Browse All TopicsI need to know how to return the datediff between two values in a field formula I tried the syntax below (see code) with no luck:
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Ok I am kind of getting somewhere now... The following:
If {Months_Of_Service.HR_JOB_
totext(Date({Months_Of_Ser
else
"Nothing"
Is working but what I am looking to do is calculate the months of service given up and until the current date. The formula above is not rendering that.
-D-
Where/How are you using that formula? The formula that you posted and, consequently, the formulas suggested by others, all return a number. If you're getting an error saying that the result must be a string, it's because of where/how you're using that formula.
Or, to put it another way, what output do you _want_ the formula to produce?
You say that you want months, but if the formula is supposed to produce a string, what do you want it to say?
Do you want whole months or something more detailed? For example, would 01/10 - 02/20 (41 days) be 1 month?
If you're looking for whole months, try:
If {Months_Of_Service.HR_JOB_
DateDiff ("m", {Months_Of_Service.DATE_ST
Note that this is essentially the same thing suggested by the first two replies to your question. It's just a matter of changing the first argument to DateDiff to get the correct "units" (days, weeks, months, etc.).
To get that number as a string:
If {Months_Of_Service.HR_JOB_
CStr (DateDiff ("m", {Months_Of_Service.DATE_ST
James
James,
Thank you for your replies so far. The following:
If {Months_Of_Service.HR_JOB_
totext(DateDiff ("m", {Months_Of_Service.DATE_ST
else
"Nothing"
With your changes renders the months of service. The problem I have is Job Class "CE" is considered a 10 month position and each year of service should render only 10 months of credit. How would you work that into the formula?
-D-
You had not posted that last message when I started writing my last message.
What are you trying to do in that last formula, because what you are actually doing makes no sense at all.
"Date(year(CurrentDate))"
Year (CurrentDate) is 2009.
Date (2009) converts that number to a date, which gives you 07/01/1905 (July 1st, 1905).
"Date(Year({Months_Of_Serv
Year({Months_Of_Service.DA
Date (2008 * 10) = Date (20080), which gives you 12/22/1954.
07/01/1905 - 12/22/1954 is -18,071 days, which I'm pretty sure is not what you're looking for. :-)
James
> The problem I have is Job Class "CE" is considered a 10 month position
> and each year of service should render only 10 months of credit.
I'm not sure what you mean there. Are you saying that 1 year (12 months) only counts as 10 months somehow, or 10 months count as 1 year, or ...?
This basically brings me back to what I asked before. What output do you want the formula to produce?
How about some specific examples? Using 9, 10, 11, 12 and 13 months as examples, what should the formula say for each of those?
James
So, you don't really want to count the months between the dates. You want to count the years and then convert that to a corresponding number of months (years * 10 or years * 14). Correct?
Do you care about parts of a year? For example, if the dates are 20 months apart, that's 1.67 years. Does that just count as 1 year?
If so, then what you've got there should work. Do the same kind of thing for code "14", but multiply by 14.
James
I'm not sure what you mean. Are you saying that if, for example, the two dates were 400 days apart, which translates to approx 1.095 years, you'd want to multiply that by 10 or 14, giving you 10.95 or 15.33 months, respectively? If so, do you want to show any decimal places on the resulting month count?
James
You can get a pretty accurate conversion from days to years by dividing by 365.25. That's the simplest approach. For example:
If {Months_Of_Service.HR_JOB_
totext(DateDiff ("d", {Months_Of_Service.DATE_ST
If you wanted, you could get more detailed, for example by getting the difference in whole years, and then getting a separate count for the additional days and converting that to a fraction of a year (taking into account whether or not a leap year was involved).
James
Business Accounts
Answer for Membership
by: BSAS_ITGuyPosted on 2009-02-19 at 14:18:19ID: 23686875
Try
CLASS_CODE } = "CE" then _Service.D ATE_START} , CurrentDate )
If {Months_Of_Service.HR_JOB_
Datediff("yyyy",{Months_Of
else
0
What are you trying to find months, years , weeks?