Date Calculation.,.

D

Dragon

I have a table with the following fields:

FName/Text LName/Text DOB/Date Days/Int
John Smith 01/01/70 14
Jane Dow 03/15/75 10
Erik Jones 03/25/72 10

I would like to get all the records that have a DOB coming up within the
number of days specified in the Days field.

For Example, if I run the query on the data above, I should get the
following:

FName/Text LName/Text DOB/Date Birthday Years
Jane Dow 03/15/75 03/15/2005 30

Any ideas how would I go about it?

Thanks.
 
A

Allen Browne

Try something like this:

DateDiff("d", Date(),
IIf(DateSerial(Year(Date()), Month([DOB]), Day([DOB]) < Date(),
DateSerial(Year(Date())+1, Month([DOB]), Day([DOB]),
DateSerial(Year(Date()), Month([DOB]), Day([DOB]))) < [DaysInt]
 
P

Per Larsen

Maybe somrthing like:

SELECT FName,
LName,
DOB,
DateAdd("yyyy", Year(Date)- Year(DOB), DOB) AS Birthday,
Year(Date)- Year(DOB) AS Years
FROM table
WHERE DateDiff("d", Date(), DateAdd("yyyy", Year(Date)- Year(DOB), DOB)) < Days

hth

PerL
 
D

Dragon

Thank you everyone. I will give it a try :)


Per Larsen said:
Maybe somrthing like:

SELECT FName, LName, DOB, DateAdd("yyyy", Year(Date)- Year(DOB), DOB) AS
Birthday, Year(Date)- Year(DOB) AS Years
FROM table
WHERE DateDiff("d", Date(), DateAdd("yyyy", Year(Date)- Year(DOB), DOB))
< Days

hth

PerL
 

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

Similar Threads


Top