Count Years

I

Iram

Hello,
I have a continuous form with the following fields, First Name, Last Name,
Date Arrived.

In the continuous form next to these fields I would like to add a field
called Years that calculates how many years since they have arrived for
example...

First Name Last Name Date Arrived Years
John Johnson 01/27/2008 2.1

How do I write the logic into the Years field?

I would need it exact with one digit after the decimal as shown above, but
not two digits after the decimal.

In a report I would need similar logic but I would need the logic to
determine how many years the person has been here based upon a date I put in
a form in a field called "OnDate". In other words how many years between the
date arrived and the date I put on a form.

Can you please help me with this?

Thanks.
Iram/mcp
 
J

John W. Vinson

Hello,
I have a continuous form with the following fields, First Name, Last Name,
Date Arrived.

In the continuous form next to these fields I would like to add a field
called Years that calculates how many years since they have arrived for
example...

First Name Last Name Date Arrived Years
John Johnson 01/27/2008 2.1

How do I write the logic into the Years field?

I would need it exact with one digit after the decimal as shown above, but
not two digits after the decimal.

In a report I would need similar logic but I would need the logic to
determine how many years the person has been here based upon a date I put in
a form in a field called "OnDate". In other words how many years between the
date arrived and the date I put on a form.

Can you please help me with this?

Thanks.
Iram/mcp

A calculated field in your query such as

Years: Round(DateDiff("d", [Date Arrived], [Forms]!{YourFormName]![OnDate]) /
365.25, 1)

should work.
 
I

Iram

I did a calculated field in a query a long time ago,
Can you refresh my memory on how to do it exactly?



Thanks.
Iram/mcp

John W. Vinson said:
Hello,
I have a continuous form with the following fields, First Name, Last Name,
Date Arrived.

In the continuous form next to these fields I would like to add a field
called Years that calculates how many years since they have arrived for
example...

First Name Last Name Date Arrived Years
John Johnson 01/27/2008 2.1

How do I write the logic into the Years field?

I would need it exact with one digit after the decimal as shown above, but
not two digits after the decimal.

In a report I would need similar logic but I would need the logic to
determine how many years the person has been here based upon a date I put in
a form in a field called "OnDate". In other words how many years between the
date arrived and the date I put on a form.

Can you please help me with this?

Thanks.
Iram/mcp

A calculated field in your query such as

Years: Round(DateDiff("d", [Date Arrived], [Forms]!{YourFormName]![OnDate]) /
365.25, 1)

should work.
 
J

John W. Vinson

I did a calculated field in a query a long time ago,
Can you refresh my memory on how to do it exactly?

Open the query in design view.

Find a vacant Field cell in the top row.

Type the expression into that field cell; in this case just type or copy and
paste

Years: Round(DateDiff("d", [Date Arrived], [Forms]![YourFormName]![OnDate]) /
365.25, 1)

into that cell, all on one line, replacing "YourFormName" with the actual name
of the form that you are using.
 
I

Iram

Cool Thanks that worked John!

I have a calculated field in a different query that I need to fix, why
doesn' this work?

Years: Round(DateDiff("d",[FechaEntroObra],Date())/365.25,1)

I need a year count between the field "FechaEntroObra" and today's date.


Thanks.
Iram/mcp



John W. Vinson said:
I did a calculated field in a query a long time ago,
Can you refresh my memory on how to do it exactly?

Open the query in design view.

Find a vacant Field cell in the top row.

Type the expression into that field cell; in this case just type or copy and
paste

Years: Round(DateDiff("d", [Date Arrived], [Forms]![YourFormName]![OnDate]) /
365.25, 1)

into that cell, all on one line, replacing "YourFormName" with the actual name
of the form that you are using.
 
J

John W. Vinson

Cool Thanks that worked John!

I have a calculated field in a different query that I need to fix, why
doesn' this work?

Years: Round(DateDiff("d",[FechaEntroObra],Date())/365.25,1)

I need a year count between the field "FechaEntroObra" and today's date.

In what way does it "not work"? What happens if you build it up piecewise:
first DateDiff("d", [FechaEntroObra], Date()), then the division, then the
round? What's actually in the FechaEntroObra field - a date/time value as the
name suggests, or is it perhaps a date in a Text field?
 

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