rsgfmp Posted July 20, 2004 Posted July 20, 2004 Quick question: I have a calculation field set to calculate age: (TODAY - Current Date)/365.25 This works, but the field either rounds the age up or returns 32.99 years old or 18.24 years old, etc. How can I make this calculation field always round DOWN to the nearest full integer (no decimals or rounding up)? Shane
Lee Smith Posted July 20, 2004 Posted July 20, 2004 isn't Today dead in 7? and isn't Today and Current Date the same Date? I don't have 7, so this maybe easier. Here is the calculation I use in v6. (Year(ReferenceDate) - Year(Birthday) - If((ReferenceDate) < Date(Month(Birthday), Day(Birthday), Year(ReferenceDate)), 1,0))&" "&"Years,"&" "& Mod(Month(ReferenceDate) - Month(Birthday) + 12 - If((Day(ReferenceDate) < Day(Birthday)),1,0),12)&" "&" months,"&" "&"and " & Round(Mod(Day(ReferenceDate) - Day(Birthday) + 30.42+1 - If((Day(ReferenceDate) < Day(Birthday)),1,0),31),0) &" days." Text result. Lee
rsgfmp Posted July 20, 2004 Author Posted July 20, 2004 Sorry, I meant: (TODAY - Date of Birth)/365.25 "TODAY" does seem to work, at least for me, in 7. Shane
Newbies fmforumuser Posted July 20, 2004 Newbies Posted July 20, 2004 If you just want to see the years, this might work: Truncate( (Status(CurrentDate)-birthday)/365.25, 0). Use status (currentdate) not today() and make the field unstored if you can. Hope this helps
-Queue- Posted July 20, 2004 Posted July 20, 2004 The Floor function may be what you're looking for in version 7. Here's a tweaked version of Lee's calc, combining the text that need not be separated, simplifying the already booleanized Ifs, and changing commas to semicolons for version 7, if this suits your needs... Year(ReferenceDate) - Year(Birthday) - (ReferenceDate < Date(Month(Birthday); Day(Birthday); Year(ReferenceDate))) & " Years, " & Mod(Month(ReferenceDate) - Month(Birthday) + 12 - (Day(ReferenceDate) < Day(Birthday)); 12) & " months, and " & Round(Mod(Day(ReferenceDate) - Day(Birthday) + 30.42 + 1 - (Day(ReferenceDate) < Day(Birthday)); 31); 0) & " days"
rsgfmp Posted July 20, 2004 Author Posted July 20, 2004 Thank you Lee and Queue, I justed needed the year only, so I modified and deleted the portion not needed. Also, Lee, I was wrong, I had TODAY listed as a field in my table referenced to the CurrentDate. Sorry. Shane
Recommended Posts
This topic is 7500 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 accountSign in
Already have an account? Sign in here.
Sign In Now