Jump to content

Years of service


This topic is 520 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Fields: 

ACTIVE = YES value 

DATE STARTED

DATE ENDED

gDATE_TODAY = global Get(Current_Date)

YEARS OF SERVICE (calculated result)

If the ACTIVE field is "yes" then I want to see current YEARS OF SERVICE  from today. Else, I want to see YEARS OF SERVICE  from start to end date.

Tried scenario that isn't quite working: 

If (Active="yes"; Year (Date_Today) - Year (Date_Started); Year (Date_Ended) - Year (Date_Started))

Edited by Raizel
Link to comment
Share on other sites

I entered the calculation however it does not take into consideration there maybe one date (start) so result needs to be from start date to today (gDATE_TODAY) (not sure if this field needs to be global)

Link to comment
Share on other sites

I don't see why you need both the Active field and the Date_Ended field: after all, if someone is inactive, then they have a value in the Date_Ended field, do they not? 

If so, the calculation you started could be simply:

Let ( 
end = If ( Date_Ended ; Date_Ended ; Get ( CurrentDate ) )
;
Year ( end ) - Year ( Date_Started )
)

The result type is Number and the calculation field must be unstored.

However, simply subtracting the years is not a very precise calculation of age. A more accurate method would also include the fractional part of the (average) year:

Let ( 
end = If ( Date_Ended ; Date_Ended ; Get ( CurrentDate ) ) 
; 
( end - Date_Started ) / 365.2425 
)

You can round the result to desired precision or simply format the field to display a fixed number of decimals.


P.S. There is absolutely no need to have a global field with the current date. 

 

 

Link to comment
Share on other sites

The ACTIVE field is a value of YES for more visual means of an active charity. I changed the calculation to the last shown and it's working rounded to one decimal to display. Removed the global field. Thanks

Link to comment
Share on other sites

8 minutes ago, Raizel said:

The ACTIVE field is a value of YES for more visual means of an active charity.

This is not good practice. The entire idea of a relational database is to record each fact in one place only. You have plenty of ways to provide a visual indication of the status, based on the value (or absence thereof) in the Date_Ended field. For example, you could conditionally hide a text object.

 

Link to comment
Share on other sites

This topic is 520 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.