3 Replies Latest reply on Aug 18, 2012 6:59 PM by RossHurley

# Using Year Function in a Calculation

Hi all,

I’m not getting the expected result when using the Year function in a calculation. Simplified, the calc is:

Year (Get ( CurrentDate )) - Year (AnotherDateField)

If AnotherDatefield is, eg, 1/1/2010, I want to get an answer ‘2’, ie 2012 - 2010 = 2. But this calculation always returns ‘2011’.

It returns ‘2011’ whatever the date in AnotherDateField is, so I can work out that the ‘Year (AnotherDateField)’ part of the calc is resolving as True, therefore 1, so 2012 - 1 = 2011. But that isn’t really the issue. I want to calculate the difference in number of years between two dates, eg, 2012 - 2010 = 2. Wrapping the calc in GetAsNumber doesn’t change the result, nor does wrapping the two parts of the calc individually in GetAsNumber. It seems it should be a simple calculation but I can’t figure it out. Any help would be appreciated.

Ross Hurley

Adelaide, Australia

• ###### 1. Re: Using Year Function in a Calculation

Hi Ross,

Odd, it works here, see sample.

Best regards,

Ruben van den Boogaard

Infomatics Software

ruben@infomatics.nl

• ###### 2. Re: Using Year Function in a Calculation

RossHurley wrote:

Simplified, the calc is:

Year (Get ( CurrentDate )) - Year (AnotherDateField)

Well, Year (Get ( CurrentDate )) - Year (AnotherDateField) does NOT return 2011 - so perhaps your formula doesn't simplify exactly to that.

1 of 1 people found this helpful
• ###### 3. Re: Using Year Function in a Calculation

Yes Ruben, you're right. Playing around in Data View I was using another field with an almost identical name. This was a number field, not a date field. Replacing it with the correct field does get me the answer I want. Sorry for wasting everyone's time, but thanks for checking it out for me.

Regards,

Ross Hurley