Calculating age on a specific date

  • Permalink
  • submit to reddit
  • Email
  • Follow


In my database for a 10K Run I need to calculate the age a runner will
be on 3/19/2011 (using their DOB)

Been using:
Case(Date(Month(DOB);Day(DOB);Year(Modification))>Modification;Year(Modification)-
Year(DOB)-1;Year(Modification)-Year(DOB))

which gives me the age of the person on the date I open the database.
How do I make it so it will show the age the runner will be on
3/19/2011?

Thanks!
1
Reply lynne 1/5/2011 4:37:41 AM

See related articles to this posting


"lynne" <computer.1on1@gmail.com> wrote in message
news:df046580-beb6-436b-aa21-47c93034861b@j32g2000prh.googlegroups.com...
> In my database for a 10K Run I need to calculate the age a runner will
> be on 3/19/2011 (using their DOB)
>
> Been using:
>
Case(Date(Month(DOB);Day(DOB);Year(Modification))>Modification;Year(Modifica
tion)-
> Year(DOB)-1;Year(Modification)-Year(DOB))
>
> which gives me the age of the person on the date I open the database.
> How do I make it so it will show the age the runner will be on
> 3/19/2011?
>
> Thanks!

You'll probably want to be able to change the deate you're using for the age
test, so the best approach would be to create a new Global Date Field,
e.g.       RaceDate     Global    Date

and put it on a Layout where it's easily accessible. Then for this
particular example type the date "3/19/2011" into the new Field (without the
quote marks).

Then you can create a duplicate of that Field you're using above and change
the Modification Field to be the new RaceDate Field.
i.e.
       RaceAge        Calculation, Unstored, Number Result
          =  Case(Date(Month(DOB); Day(DOB); Year(RaceDate))>RaceDate;
                       Year(RaceDate) - Year(DOB)-1;
                       Year(RaceDate) - Year(DOB))

Now, whenever you change the RaceDate Field's data, the RaceAge will
recalculate.


Note: These types of database-wide calculations can be quite slow on older
computers. I use to run a similar system for triathlons around 15 years ago
on a Mac Classic. I set the database to open automatically each morning when
the computer was turned on and re-calculate the ages as of "today" ... it
used to take about 20 minutes to go through all the records. On a modern
computer it would probably take closer to 20 seconds for the same number of
records.

Helpful Harry  :o)




0
Reply Your 1/5/2011 5:27:50 AM

On Jan 4, 9:27=A0pm, "Your Name" <your.n...@isp.com> wrote:
> "lynne" <computer.1...@gmail.com> wrote in message
>
> news:df046580-beb6-436b-aa21-47c93034861b@j32g2000prh.googlegroups.com...=
> In my database for a 10K Run I need to calculate the age a runner will
> > be on 3/19/2011 (using their DOB)
>
> > Been using:
>
> Case(Date(Month(DOB);Day(DOB);Year(Modification))>Modification;Year(Modif=
ica
> tion)-
>
> > Year(DOB)-1;Year(Modification)-Year(DOB))
>
> > which gives me the age of the person on the date I open the database.
> > How do I make it so it will show the age the runner will be on
> > 3/19/2011?
>
> > Thanks!
>
> You'll probably want to be able to change the deate you're using for the =
age
> test, so the best approach would be to create a new Global Date Field,
> e.g. =A0 =A0 =A0 RaceDate =A0 =A0 Global =A0 =A0Date
>
> and put it on a Layout where it's easily accessible. Then for this
> particular example type the date "3/19/2011" into the new Field (without =
the
> quote marks).
>
> Then you can create a duplicate of that Field you're using above and chan=
ge
> the Modification Field to be the new RaceDate Field.
> i.e.
> =A0 =A0 =A0 =A0RaceAge =A0 =A0 =A0 =A0Calculation, Unstored, Number Resul=
t
> =A0 =A0 =A0 =A0 =A0 =3D =A0Case(Date(Month(DOB); Day(DOB); Year(RaceDate)=
)>RaceDate;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Year(RaceDate) - Year(DOB)=
-1;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Year(RaceDate) - Year(DOB)=
)
>
> Now, whenever you change the RaceDate Field's data, the RaceAge will
> recalculate.
>
> Note: These types of database-wide calculations can be quite slow on olde=
r
> computers. I use to run a similar system for triathlons around 15 years a=
go
> on a Mac Classic. I set the database to open automatically each morning w=
hen
> the computer was turned on and re-calculate the ages as of "today" ... it
> used to take about 20 minutes to go through all the records. On a modern
> computer it would probably take closer to 20 seconds for the same number =
of
> records.
>
> Helpful Harry =A0:o)

Helpful you most certainly were Harry.  Funny, was walking along the
ocean this morning and pondering this database age query and the very
obvious (oh silly me) solution came up to make a global date field and
come home and found your answer.  You must have tossed it into the
collective consciousness when you replied.  Thank you! For of course,
it works perfectly. Many thanks.
0
Reply lynne 1/9/2011 8:12:23 AM
comp.databases.filemaker 10762 articles. 18 followers. Post

2 Replies
1658 Views

Similar Articles

[PageSpeed] 55


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

how to calculate age from dob and another date with strange date
*IF* you have no other use for these variables as dates, and *IF* by age you mean the conventional sense of "having passed the xth anniversary of birth," then there's really no reason to do fancy date arithmetic, since the given format (I'd call it pretty standard, not strange) puts year, month, and day in a convenient way: Let's assume that the dates are in character variables, dob_c and admis_c: /* convert to numerics */ dob = input(dob_c,8.) ; admis = input(admis_c,8.) ; /* calculate number of years passed */ age = int( ( admis - dob ) / 10000 ) ; (Th...

how to calculate age from dob and another date with strange date format?
Hi, I am wondering if anyone can help me with my situation. I have two date variables that I want to use to calculate age. One is date of birth and the other one is a admission date. These two variables are in strange format yearmonthday so 20040105 means Jan-05-2004. I believe both are just character variables Can someone show me how I can calculate age of this person at admission? Thanks so so much for any insight! Jye It's not really that strange of a date format. It is actually an ISO standard (I forget the number)... If it is a character variable, you can convert it into a SA...

calculating age as on a date.....
Hi, I have to calculate the present of as on 20091101(yyyymmdd) of a given date of birth. I hav the following file. I have the following file. name dob (this not the part of datafile) xx 19540501 yy 19660101 zz 19920802 here dob is in yyyymmdd (if the fraction of months is greater than 6 months then age take the higher value) I have done with the following code(raw method) and i got the age. But is there any simple method to calculate the same. #age as at 01.11.2009 by=substr($0,8,4)+0 bm=substr($0,12,2)+0 bd=substr($0,14,2)+0 if(bd>1 && bm ...

Calculating specific dates
Preface: I don't care if the solution is written in Data step, SQL, or Macro or machine code, but the customer doesn't have AF, so that rules out SCL. (Sorry!) Given a certain year & quarter (financial or calendar - don't mind), I need to determiune the last Wednesday of that quarter. For example: MyDate = Function(Year=2005, CalQtr=3) = "28Sep2005"d. Thanks, Andrew. ------------------------------------------------------------ This email was sent from Netspace Webmail: http://www.netspace.net.au ...

Age on specific date
Hi, I'm sure this is something that has been asked here many times! I wish to display the age that someone will be on a specific advanced date e.g. 1st April 2004. I guess this would be run in a query? I have been given the following formula: (date()-[DOB])/365 is this correct and can it be used in a database? And, now the ultimate question if this formula will work in a database what do I do with it? Many thanks in anticipation. Jeff. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.495 / Virus Database: 294 - Rele...

Re: Calculating specific dates
Andrew, A function expression will do, which is best packaged as a macro, even when SCL is available. The macro can be called anywhere a function call is allowed. /* For example: MyDate = Function(Year=2005, CalQtr=3) = "28Sep2005"d. */ %macro LastWedQtr ( year , qtr ) ; intnx( "week.4" , (intnx("month", mdy(1,1,&year), 3*&qtr) - 1) , 0 ) %mend lastwedqtr ; data _null_ ; wanted = %lastwedqtr(2005,3) ; put wanted= weekdatx. ; do year = 2005 to 2010 ; do qtr = 1 to 4 ; ...

help
Hi can anyone help,pls I need to be able to calculate a person's [age] in years at a [specified date] from their [DoB] I have tried [specified date] - [DoB] but that gives a serial date result not the age in years. I have also tried more complex formulae using Month() & year() but can't find eq for day() Does anybody have a suitable formulae they would like to share. Thanks Scutz (please post answer to group) In reply to aWoeb.4885$d6.201063@nasal.pacific.net.au on 9/30/03 5:08 PM by Scutz scutz@start.com.au: Put this into a your calculation field with the result of t...

Re: Calculating specific dates #2
See http://tinyurl.com/fa6vq Keep in mind that the last Xxxday of some calendar interval is the first Xxxday of the following interval, minus 7. On Mon, 20 Mar 2006 10:02:49 +1100, Andrew Howell <ahowell@NETSPACE.NET.AU> wrote: >Preface: I don't care if the solution is written in Data step, SQL, or Macro or >machine code, but the customer doesn't have AF, so that rules out SCL. (Sorry!) > >Given a certain year & quarter (financial or calendar - don't mind), I need to >determiune the last Wednesday of that quarter. > >For example: MyDate = Function(...

Re: Calculating specific dates #3
Andrew , Seems simple enough, there is probably a more elegant solution but this seems to work and was simple to code up. %macro LastWed( Year = , Qtr = ) ; %local LastWed ; %let LastWed = %sysfunc( intnx(Quarter , "01Jan&Year"d - 1 , &Qtr , End ) ) ; %do %until ( %sysfunc( WeekDay(&LastWed) ) = 4 ) ; %let LastWed = %sysfunc( intnx( Day , &LastWed , -1 ) ) ; %end ; &LastWed %mend LastWed ; Data _null_ ; y = %LastWed( Year = 2005 , Qtr = 3 ) ; put y = date9. ; run ; Toby Dunn From: Andrew Howell <ahowell@NETSPACE.NET.AU> Reply-To: ahowell...

Re: Calculating specific dates #4
Try this: data _null_; do Year = 2005 to 2020; do CalQtr = 1 to 4; LastWednesday = intnx('week.4', intnx('qtr', mdy(CalQtr*3,1,Year), 0, 'end'), 0); format LastWednesday weekdate.; put LastWednesday=; end; end; run; Results: LastWednesday=Wednesday, March 30, 2005 LastWednesday=Wednesday, June 29, 2005 LastWednesday=Wednesday, September 28, ...

Re: Calculating specific dates #5
Andrew: You may use intnx('week.4',QuarterEndDate,0) to find the last Wednesday of that quarter. The following code and log window verify all quarter in year 2005 - 2010. You may modify to change the starting and end years. data _null_; do year=2005 to 2010; do month=3 to 12 by 3; select (month); when (3) day=31; when (6) day=30; when (9) day=30; when (12) day=31; end; qtrend=mdy(month,day,year); date=intnx('week.4',qtrend,0); put date=weekdatx.; end; end...

Calculating week range from specific date
Help, I am sure this has been asked before but it is difficult to search for. Given a date, is there a function or a already written script out there that will allow my to get the previous Monday before the date given? This is so that given the current date, I can show all events that are happening for that week. I also will want to do the same for the month. I know I could go about writing algorithms to calculate this, but I am sure this is something that has been done numerous times before. Also is there anywhere out there built an easy to plug in calendar view function that rather then m...

Age calculation based on birth date & today
I work for a life insurance company and our rates are based on current age. I set up a calculation using: Round( (Today-DOB) / 365, 0) This gets it close, but not accurate enough. If I enter DOB as 4-10-1939 on 4-1-04, I get "65" even though they wouldn't be 65 for 9 more days. Is there a more accurate calculation than dividing by 365? -- Sincerely, Kenny Year(Status(CurrentDate)) - Year(DOB) - (DayofYear(Status(CurrentDate)) < DayofYear(DOB)) mICHAEL mYETT Kenny Sturm wrote: > I work for a life insurance company and our rates are based on current age. > I ...

Re: how to calculate age from dob and another date with strange
jye , Data _null_ ; DOB = '19750327' ; Admission= '20050105' ; NewDob = Input( DOB , yymmdd8. ) ; NewAdm = Input( Admission , yymmdd8. ) ; Age = INT( ( INTCK( 'MONTH' , NewDOB , NewAdm ) - ( DAY( NewDOB ) > DAY( NewAdm ) ) ) / 12 ) ; put Age= ; run ; Toby Dunn From: Jye <wang0641@GMAIL.COM> Reply-To: Jye <wang0641@GMAIL.COM> To: SAS-L@LISTSERV.UGA.EDU Subject: how to calculate age from dob and another date with strange date format? Date: Thu, 1 Jun 2006 12:37:11 -0700 Hi, I am wondering if anyone can help me with my si...

Re: how to calculate age from dob and another date with strange #4
Did a quick Google... It's ISO 8601 to be exact. "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> wrote on 06/01/2006 04:27:20 PM: > It's not really that strange of a date format. It is actually an ISO > standard (I forget the number)... > > If it is a character variable, you can convert it into a SAS date variable > using the YYMMDDn. informat. > > For example: > char_date='20040105'; > num_date=input(char_date,yymmdd8.); > > > > > "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> wrote on 06/01/2006 03:37:11...

Calculate the number of work days between two dates with specific days off
I would like to calculate the number of "work days" between two dates; however, the "regular days off" are may not be Sat and Sun and they may not be consecutive. Is there a way to calculate the number of days between two dates that deducts certain "days off"? Thus, it could calculate the number of work days for a person with Mondays and Thursdays off and then calculate the number of work days for a person with Saturdaya and Mondays off. (I would ove to be able to enter the two days off and then get the number of work days between two dates which keeps ...

Help Needed For Date field (Age) Calculation In SQl query
Hi experts, I am working on SQL server 2005 reporting services and i am getting a problem in writting a query. Situation is given below. There is one table in database Named Child Now i have to find the All childrens whoes Age is 13 years Base on Some given parameter. If User select Augus 2007 then It has to calculate the Childs who born in August 1994 And if he select September Then query should show only those child Who born in September 1994 and so on..... And use can select another year month also like August 2009 ... I am writting the following query Select Child_Name, DOb f...

Re: how to calculate age from dob and another date with strange d
> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Jye > Sent: Thursday, June 01, 2006 12:37 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: how to calculate age from dob and another date with strange date > format? > > Hi, > > I am wondering if anyone can help me with my situation. I have two date > variables that I want to use to calculate age. One is date of birth and > the other one is a admission date. These two variables are in strange > format yearmonthday so 20040105 means Jan-05-2004. I believe both ar...

Re: how to calculate age from dob and another date with strange #2
It's not really that strange of a date format. It is actually an ISO standard (I forget the number)... If it is a character variable, you can convert it into a SAS date variable using the YYMMDDn. informat. For example: char_date='20040105'; num_date=input(char_date,yymmdd8.); "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> wrote on 06/01/2006 03:37:11 PM: > Hi, > > I am wondering if anyone can help me with my situation. I have two date > variables that I want to use to calculate age. One is date of birth and > the other one is a admission date. T...

Re: how to calculate age from dob and another date with strange #3
Jye: Try the following code with its output following. data temp; input dob:yymmdd8. addate:yymmdd8.; format dob addate date9.; datalines; 19810101 19811231 19810101 20010101 19810101 20011231 19810830 20060601 19860903 20060905 19720229 20060228 19720229 20060301 19720229 20080229 ; run; data Result(drop=adjustment); set temp; adjustment=((month(dob) gt month(addate)) or ((month(dob) eq month(addate)) and (day(dob) gt day(addate)))); age=intck('year',dob,addate)-adjustment; run; proc print data=Result; run; ***** OUTPUT ***** DATA SET For DATASET103 08:07 Thursday, June 1, 2006...

Re: how to calculate age from dob and another date with strange d #2
Shalu: The suggestion you made will work for almost all cases except some case like the following. With yrdiff, it will calculate the one born on 28Feb1995 with age less than one on the first birthday 28Feb1996. This is due to the definition in yrdiff as the number of days in 365-day years divided by 365 plus the number of days in 366-day year divided by 366. In this case it is 307/365 + 58/366 = 0.9995658358. 2217 data _null_; 2218 sdate='28Feb1995'd; 2219 edate='28Feb1996'd; 2220 yactact=yrdif(sdate, edate, 'ACT/ACT'); 2221 put yactact=; 2222 run; yactact=0.999...

Calculate by Date (non date fields)
I am calculating actual costs against a budget and have stumbled upon a problem. For estimating each months hours i have setup text fields for our Program Managers(PM) to put in approximate hours to complete a task. So I have a fields called Jan; Feb; Mar; .... These fields are a bucket to hold estimated hours. But if I want to compare the actuals to the budget as of this month how do i do that. So since it is November right now I want to compare actuals from Jan-Nov and also add up the totals of estimates from Jan-Nov. However when December rolls around I want it to automatically calcula...

Calculated Date = 4 weeks before Date ... How ?
Hi, I need a Calculated Date = 4 weeks before Date which is in table ... How ? -- Dave Allison ~ Scotland Create a query into this table. If the field is called MyDate, type this into a fresh column of the query design grid: CalcDate: DateDiff("d", -28, [MyDate]) -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "David Allison" <david.allison@zzzz@zzzzzblueyonder.co.uk> wrote in message news:MS4vb.12897$zQ.6577@news-binary.blueyonder...

date/time calculations: calculating exact difference
Hi all, I have been struggling with a problem all day, I have been unable to come up with a working solution. I want to write a function which takes 2 unix timestamps and calculates the difference. I want it to return the difference in years, months, days, hours, minutes and seconds (a complete summary). Keeping into account of course that these are 2 real dates, I dont want it to work with 30.475 as an average number of days in a month, I want it to work with the supplied months/years. The output ought to be: there is 0 years, 7 months, 12 days, 5 hours, 56 minutes and 51 seconds differenc...