473,465 Members | 4,818 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Age Calculation in the future

Hello-

I've looked at all the age calulation solutions - but I'm a little
stumped on how to set this one up. Here is what I need to do.

I need to find all the kids in my DB that are currently 11 or 12 years
of age
AND
All the kids who WILL BE 11 on or before Dec 31, 2005.

The current kids aren't an issue - but how do I calculate who is 10 now
and will have a birthday between tomorrow and 12/31/05 ???

Appreciate any suggestions,
john-

Nov 13 '05 #1
5 2767

<jo*****@zeus.kern.org> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hello-

I've looked at all the age calulation solutions - but I'm a little
stumped on how to set this one up. Here is what I need to do.

I need to find all the kids in my DB that are currently 11 or 12 years
of age
AND
All the kids who WILL BE 11 on or before Dec 31, 2005.

The current kids aren't an issue - but how do I calculate who is 10 now
and will have a birthday between tomorrow and 12/31/05 ???

Appreciate any suggestions,
john-

To find the kids who are 10 now but will be 11 by the end of the year is
easy enough, but do you realise that some of the kids who are currently 11
or 12 may no longer be 11 or 12 by the end of the year?
Imagine you write a function which takes the kid's date of birth and the
'EventDate' (could be today or a date in the future) and it returns the
number of years old. If you want to generalise the function so it handles:
How old will the person be at the end of this year? How old was the person 5
years ago? you will need to think about negative numbers. My function
ignores dates in the past and simply returns zero.
If there is a field for date of birth called [DOB] you could write:
AgeNow:AgeOnDate(Date(),[DOB])
AgeAtYearEnd:AgeOnDate(DateSerial(Year(Date(),12,3 1),[DOB])
Public Function AgeOnDate(dteDate As Date, dteBirthDate As Date) As Long

If dteDate > dteBirthDate Then
AgeOnDate = DateDiff("yyyy", dteBirthDate, dteDate) - _
IIf(Format(dteDate, "mmdd") < _
Format(dteBirthDate, "mmdd"), 1, 0)
End If

End Function
Nov 13 '05 #2
jo*****@zeus.kern.org wrote in
news:11**********************@g14g2000cwa.googlegr oups.com:
Hello-

I've looked at all the age calulation solutions - but I'm a
little stumped on how to set this one up. Here is what I need
to do.

I need to find all the kids in my DB that are currently 11 or
12 years of age
AND
All the kids who WILL BE 11 on or before Dec 31, 2005.

The current kids aren't an issue - but how do I calculate who
is 10 now and will have a birthday between tomorrow and
12/31/05 ???

Appreciate any suggestions,
john-

take your 11 years off of Dec 31, 2005.
that gives you Dec 31, 1994
compare that date to the birthday. if the birthdate is less,
they will be 11 by Dec 31.

If you also calculate the makimum date that a kid can be and be
12 today, (that's October 19,1992)
you can select all kids by testing for

Birthdate between #10/19/92# and#12/31/94#

--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #3
jo*****@zeus.kern.org wrote:
Hello-

I've looked at all the age calulation solutions - but I'm a little
stumped on how to set this one up. Here is what I need to do.

I need to find all the kids in my DB that are currently 11 or 12 years
of age
AND
All the kids who WILL BE 11 on or before Dec 31, 2005.

The current kids aren't an issue - but how do I calculate who is 10 now
and will have a birthday between tomorrow and 12/31/05 ???

Appreciate any suggestions,
john-


To get those who are 11 or 12 now plus those who will be 11 on
12/31/05:

SELECT * FROM tblKids WHERE Int(Format(Date(),"yyyy.mmdd") -
Format([BirthDate],"yyyy.mmdd")) = 11 OR Int(Format(Date(),"yyyy.mmdd")
- Format([BirthDate],"yyyy.mmdd")) = 12 OR Int(Format(DateSerial(2005,
12, 31),"yyyy.mmdd") - Format([BirthDate],"yyyy.mmdd")) = 11;

To get just those who are 10 now but 11 on 12/31/05

SELECT * FROM tblKids WHERE Int(Format(Date(),"yyyy.mmdd") -
Format([BirthDate],"yyyy.mmdd")) = 10 AND Int(Format(DateSerial(2005,
12, 31),"yyyy.mmdd") - Format([BirthDate],"yyyy.mmdd")) = 11;

Note that the second SQL statement uses AND instead of OR. Creating a
public function isn't much shorter. I didn't test it much. You can
incorporate Brian's Year(Date()) idea into it also instead of using
2005. Bob's idea looks good too.

James A. Fortune

Nov 13 '05 #4
There's an Age() function here:
http://allenbrowne.com/func-08.html

It lets you specify an optional date to calculate the age at, using today if
you don't specify one.

The article also explains how several common approaches don't work reliably.

--
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.

<jo*****@zeus.kern.org> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hello-

I've looked at all the age calulation solutions - but I'm a little
stumped on how to set this one up. Here is what I need to do.

I need to find all the kids in my DB that are currently 11 or 12 years
of age
AND
All the kids who WILL BE 11 on or before Dec 31, 2005.

The current kids aren't an issue - but how do I calculate who is 10 now
and will have a birthday between tomorrow and 12/31/05 ???

Appreciate any suggestions,
john-

Nov 13 '05 #5
Thank you all very much - excellent sugestions - I'm writing the report
right now, I'm sure it work great. I will study up on these solutions
and try to get a better grasp of date calculations.... this
time-machine thing always confuses me <smile>

Brian) - This report is actually a two-part request... One mailing is
to all the 11 and 12 year olds (today) and then a second group of
letters goes out to the kids who will turn 11 by 12/31.

thanks again,
john-

Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Aspersion | last post by:
I'm building an ASP page that has a lot of text and graphics. There is a calculation facility on the page. The user enters several numbers in a form and presses a button to see the calculated...
0
by: anaxamandr | last post by:
Hi. I have a long loop in ASP that performs a rather lengthy calculation. I would love for my users to be able to stop that calculation, if they so choose, mid way through the process. I attempted...
2
by: Del | last post by:
Thanks in advance for any help. I have a database that was created in Access 2000. Several users have been upgraded to Access 2003. Since upgrading to 2003 we have noticed that some of the...
4
by: Michiel Alsters | last post by:
Hello everybody, I hope anybody can help me. I'll try to give a brief overview of my problem. I have running a program that performs a heavy calculation. To give the user feedback what the...
1
by: Leonid | last post by:
Hello, Please help me with calculation parallelization. I have 2 processors DELL PRECISION 530 computer and I'd like parallelize cycles like for(int i = 0; i < last; ++i) { a = b + c; }
4
by: vg-mail | last post by:
Hello all, I have identical design for form and report but I am getting calculation error on form and everything is OK on report. The form and report are build up on SQL statement. The...
5
by: The alMIGHTY N | last post by:
Hi all, Let's say I have a simple math formula: sum (x * y / 1000) / (sum z / 1000) I have to do this across 50 items, each with an x, y and z value, when the page first loads AND when a...
3
by: mattmao | last post by:
Okay, I was asked by a friend about the result of this limit: http://bbs.newwise.com/attdata/forumid_14/20070922_fe7f77c81050413a20fbDWYOGm7zeRj3.jpg Not n->zero but n-> + infinite I really...
5
by: upyzl | last post by:
#include <stdio.h> #define digit 21 int main() { int a, b, max; int i = 0; int j = 0; int x = { 0 }; int y = { 0 };
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.