need help creating date related query

  • Thread starter mish via AccessMonster.com
  • Start date
M

mish via AccessMonster.com

I have a table that contain personal information of a number of peoples and
the table have a birthdate field which contain data of the date of birth and
the time of birth of a person . Now let say my birhdate in the record is
(12/2/1989 23:36:50)

and i would like to create a query that show the peoples who's age difference
with my age is less than 1 year. if it is too complicated to include the
calauction of the time in the expression then just ignore the time and show
only "age difference less than 1 year"

Thanks in advance
 
G

Guest

Use this as criteria --
Between DateAdd("d",-365,#12/2/1989#) And DateAdd("d",365,#12/2/1989#)
 
F

fredg

I have a table that contain personal information of a number of peoples and
the table have a birthdate field which contain data of the date of birth and
the time of birth of a person . Now let say my birhdate in the record is
(12/2/1989 23:36:50)

and i would like to create a query that show the peoples who's age difference
with my age is less than 1 year. if it is too complicated to include the
calauction of the time in the expression then just ignore the time and show
only "age difference less than 1 year"

Thanks in advance

In a query:
Age: DateDiff("yyyy",[DOB],#12/2/1989#)-IIf(Format([DOB],"mmdd")
Format(#12/2/1989#,"mmdd"),1,0)

As criteria on this field, write:
Between 0 and -1

You should get ages of less than 1 year older through less than year
younger.

If you wish to include the time of day of your birth in the
calculation, just include it as #12/2/1989 11:36:50 PM#

Then change the code to:
DateDiff("yyyy",[DOB],#12/2/1989#)-IIf(Format([DOB],"mmdd hhnnss")
 
M

mish via AccessMonster.com

fredg said:
I have a table that contain personal information of a number of peoples and
the table have a birthdate field which contain data of the date of birth and
[quoted text clipped - 7 lines]
Thanks in advance

In a query:
Age: DateDiff("yyyy",[DOB],#12/2/1989#)-IIf(Format([DOB],"mmdd")
Format(#12/2/1989#,"mmdd"),1,0)

As criteria on this field, write:
Between 0 and -1

You should get ages of less than 1 year older through less than year
younger.

If you wish to include the time of day of your birth in the
calculation, just include it as #12/2/1989 11:36:50 PM#

Then change the code to:
DateDiff("yyyy",[DOB],#12/2/1989#)-IIf(Format([DOB],"mmdd hhnnss")
Format(#12/2/1989 11:36:50 PM#,"mmdd hhnnss"),1,0)

thank you so much you guys are really helpful
 
M

mish via AccessMonster.com

fredg said:
I have a table that contain personal information of a number of peoples and
the table have a birthdate field which contain data of the date of birth and
[quoted text clipped - 7 lines]
Thanks in advance

In a query:
Age: DateDiff("yyyy",[DOB],#12/2/1989#)-IIf(Format([DOB],"mmdd")
Format(#12/2/1989#,"mmdd"),1,0)

As criteria on this field, write:
Between 0 and -1

You should get ages of less than 1 year older through less than year
younger.

If you wish to include the time of day of your birth in the
calculation, just include it as #12/2/1989 11:36:50 PM#

Then change the code to:
DateDiff("yyyy",[DOB],#12/2/1989#)-IIf(Format([DOB],"mmdd hhnnss")
Format(#12/2/1989 11:36:50 PM#,"mmdd hhnnss"),1,0)

i cannot enter this into field: it said "the expression you entered has a
function containing the wrong number of arguments
Age: DateDiff("yyyy",[DOB],#12/2/1989#)-IIf(Format([DOB],"mmdd")
 
F

fredg

fredg said:
I have a table that contain personal information of a number of peoples and
the table have a birthdate field which contain data of the date of birth and
[quoted text clipped - 7 lines]
Thanks in advance

In a query:
Age: DateDiff("yyyy",[DOB],#12/2/1989#)-IIf(Format([DOB],"mmdd")
Format(#12/2/1989#,"mmdd"),1,0)

As criteria on this field, write:
Between 0 and -1

You should get ages of less than 1 year older through less than year
younger.

If you wish to include the time of day of your birth in the
calculation, just include it as #12/2/1989 11:36:50 PM#

Then change the code to:
DateDiff("yyyy",[DOB],#12/2/1989#)-IIf(Format([DOB],"mmdd hhnnss")
Format(#12/2/1989 11:36:50 PM#,"mmdd hhnnss"),1,0)

i cannot enter this into field: it said "the expression you entered has a
function containing the wrong number of arguments
Age: DateDiff("yyyy",[DOB],#12/2/1989#)-IIf(Format([DOB],"mmdd")

You seem to have left off the rest of the expression.
Format(#12/2/1989#,"mmdd"),1,0)

it should all be on one line.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top