davedenn Posted August 11, 2004 Posted August 11, 2004 I am attempting to create a formula to automatically obtain a person's age from their date of birth. I have three fields: Date:(today's date), D.O.B., and Age:. I need the age to be automatically calculated after the user types in the patient's date of birth (D.O.B.). I know this can be done, I am just not sure of how to go about setting it up. Can someone out there help? I have attached a copy of my db if anyone cares to take a look. Dave EKGSTRESSTEST-6Copy.zip
davedenn Posted August 11, 2004 Author Posted August 11, 2004 Sorry about the empty zip file. I thought it contained the db. I'll give it another try. Thanks for letting me know. Dave
davedenn Posted August 11, 2004 Author Posted August 11, 2004 Here's the db that didn't go the first time. (I hope!). EKGSTRESSTEST-6Copy.zip
Logixx Posted August 12, 2004 Posted August 12, 2004 Dont need the db. Here is what you are looking for. GetAsText(Year(Get(CurrentDate)) - Year(DOB) - Case(Get(CurrentDate)< Date(Month(DOB); Day(DOB); Year(Get(CurrentDate))); 1)) Result is an unstored number.
JanB Posted August 12, 2004 Posted August 12, 2004 I've been looking for this calc also and ty for publishing it but it doesn't make me older after this year's birthday. eg DOB is 9/30/1967 it caculates 36 which is correct. But if i change the DOB to 11/30/1967 it still calculateds 36. ??
Logixx Posted August 12, 2004 Posted August 12, 2004 it doesn't make me older after this year's birthday. eg DOB is 9/30/1967 it caculates 36 which is correct. But if i change the DOB to 11/30/1967 it still calculateds 36. ?? What's wrong in staying 36yo another 2 months??? Obviously this calc won't get you older as long as your computer clock doesn't hit the limit. Change [color:"red"]your birthday into today or [color:"red"]your clock into your birthday and you'll see you're getting older (not necessarily wiser) right now... Got it?
JanB Posted August 12, 2004 Posted August 12, 2004 Oops - MY bad. Sorry - I need a break Thank you for hitting me with a 2x4.
davedenn Posted August 12, 2004 Author Posted August 12, 2004 I tried the code, but all I get is a ? in the Age: box. Should it be set as text or number (although both settings resulted in the same ?).
Newbies sxt Posted August 12, 2004 Newbies Posted August 12, 2004 Have it set as a calculation. Seems to work for me.
davedenn Posted August 13, 2004 Author Posted August 13, 2004 If you get a chance, could you take a look at my db from the previous post and see if you can get it to work by adding the formula to the Age: field? I must be doing something wrong, but I just can't seem to figure it out. Dave EKGSTRESSTEST-6Copy.zip
davedenn Posted August 13, 2004 Author Posted August 13, 2004 After pulling out what is left of my hair, I finally got the age/dob thing to work. My problem was that I had not set both the date and dob fields as dates. When I did that and added the below formula to the Age: field, everything worked like a charm. Int((Date - DOB) / 365) Thanks to those who tried to help me. Dave
Logixx Posted August 13, 2004 Posted August 13, 2004 Int((Date - DOB) / 365) This calc does not give the correct age all year long. Just paste the calc I previously gave you.
-Queue- Posted August 13, 2004 Posted August 13, 2004 A slight mod: you don't need the GetAsText or Case statement. Year(Get(CurrentDate)) - Year(DOB) - (Get(CurrentDate)< Date(Month(DOB); Day(DOB); Year(Get(CurrentDate))))
davedenn Posted August 14, 2004 Author Posted August 14, 2004 I finally figured it out: the simple way to do it is in the Age field, place the formula: (date-dob)/365. Make sure that both the date and dob fields are set as "date" fields and not as NUMBERS -- or anything else!! (this make the whole thing gibberish!!! Also, make sure the Age field is set as a number! Otherwise, you get some very strange calculations.... By the way, it doesn't seem to matter how you format the date and dob fields (either with slashes or dashes) Both seem to work equally well. Thanks to all who offered suggestions..... Dave
-Queue- Posted August 14, 2004 Posted August 14, 2004 As Logixx has already stated, your calculation will not give you the correct age all the time. Dividing by 365 is not a proper way to determine it. You should use the calc above.
BruceJ Posted August 15, 2004 Posted August 15, 2004 As Logixx has already stated, your calculation will not give you the correct age all the time. Dividing by 365 is not a proper way to determine it. You should use the calc above. I agree... the previously mentioned solution will work well - I've also found this to be a useful Auto Enter Calculation for the Date of Birth. This corrects the tendancy for users to enter a two digit year, it takes it to the previous century if the two digit year would result in a date beyond todays date. DOB = If(DOB>Get(CurrentDate); DOB-(36525) ; DOB) And then... Age = If(IsEmpty(DOB); Age; Year(Get(CurrentDate)) - Year( DOB) - (Get(CurrentDate) < Date(Month( DOB); Day( DOB); Year(Get(CurrentDate)))))
Tony O Posted August 16, 2004 Posted August 16, 2004 I'm looking for a calc that will give me the difference between the a timestamp field in two related records (it's a billable time db). I just need to know how much time to bill using the info. The records are related by a job# field. I'm working in FM7. I've tried using a summary field in the related table, and no luck with it so far. I know I'm missing something simple, but damned if I know what it is! : Any help is truly appreciated! TonyO
Recommended Posts
This topic is 7473 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