Calculating the DateDiff in Contacts

F

FRB

I use a custom Contact form in which I want to use a custom fied I call "Age"
and for which I want to calculate the age of the Contact. As the initial
value of this field, I use the formula:
=DateDiff("y",[Birthday], Now())
[ie, I want to display a positive value for the difference in years between
the current year and the Birthday year]
which does not give an answer. I have tried several other formulas without
success.
Does anyone have a solution to this? Thank you very much.
 
P

Pat Garard

G'Day FRB,

1. In DateDiff and DateAdd, 'y' is the format for 'Day of Year' -
you need 'yyyy' for years:
=DateDiff("yyyy",[Birthday], Now())

2. I haven't tried it, but it may also help to format:
=Format(DateDiff("y",[Birthday], Now()),'y')

3. I have a sneaky feeling that this still MAY not correctly give
the age in years - but I could be wrong.
 
F

FRB

G'Day to you Pat,
Unfortunately, changing the formula
=DateDiff("y",[Birthday], Now())
to
=DateDiff("yyyy",[Birthday], Now())
gives the following error message: "Error in Initial Value formula for
"Age" -- Missing operand before comma, ), or operator."
Thanks for trying.
FRB


Pat Garard said:
G'Day FRB,

1. In DateDiff and DateAdd, 'y' is the format for 'Day of Year' -
you need 'yyyy' for years:
=DateDiff("yyyy",[Birthday], Now())

2. I haven't tried it, but it may also help to format:
=Format(DateDiff("y",[Birthday], Now()),'y')

3. I have a sneaky feeling that this still MAY not correctly give
the age in years - but I could be wrong.
--
Regards,
Pat Garard
Melbourne, Australia
_______________________

FRB said:
I use a custom Contact form in which I want to use a custom fied I call
"Age"
and for which I want to calculate the age of the Contact. As the initial
value of this field, I use the formula:
=DateDiff("y",[Birthday], Now())
[ie, I want to display a positive value for the difference in years
between
the current year and the Birthday year]
which does not give an answer. I have tried several other formulas
without
success.
Does anyone have a solution to this? Thank you very much.
 
P

Pat Garard

G'Day again FRB,

Please try:
=DateDiff("yyyy",[Birthday], Now)
We're definitely on the right track.

I have located down a reference:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctdatediff.asp
for the vbScript DateDiff function.

"yyyy" is definitely the go for Years.

Near the very bottom of the page, just before the example, you will find:
"When comparing December 31 to January 1 of the immediately
succeeding year, DateDiff for Year ("yyyy") returns 1 even though
only a day has elapsed."
This was the basis for the doubt - I think you may have to create a
function to calculate the Years of Age correctly.
--
Regards,
Pat Garard
Melbourne, Australia
_______________________

FRB said:
G'Day to you Pat,
Unfortunately, changing the formula
=DateDiff("y",[Birthday], Now())
to
=DateDiff("yyyy",[Birthday], Now())
gives the following error message: "Error in Initial Value formula for
"Age" -- Missing operand before comma, ), or operator."
Thanks for trying.
FRB


Pat Garard said:
G'Day FRB,

1. In DateDiff and DateAdd, 'y' is the format for 'Day of Year' -
you need 'yyyy' for years:
=DateDiff("yyyy",[Birthday], Now())

2. I haven't tried it, but it may also help to format:
=Format(DateDiff("y",[Birthday], Now()),'y')

3. I have a sneaky feeling that this still MAY not correctly give
the age in years - but I could be wrong.
--
Regards,
Pat Garard
Melbourne, Australia
_______________________

FRB said:
I use a custom Contact form in which I want to use a custom fied I call
"Age"
and for which I want to calculate the age of the Contact. As the
initial
value of this field, I use the formula:
=DateDiff("y",[Birthday], Now())
[ie, I want to display a positive value for the difference in years
between
the current year and the Birthday year]
which does not give an answer. I have tried several other formulas
without
success.
Does anyone have a solution to this? Thank you very much.
 
M

Milly Staples [MVP - Outlook]

See http://www.outlook-tips.net/howto/age_form.htm

--
Milly Staples [MVP - Outlook]

Post all replies to the group to keep the discussion intact. Due to
the (insert latest virus name here) virus, all mail sent to my personal
account will be deleted without reading.

After furious head scratching, FRB asked:

| I use a custom Contact form in which I want to use a custom fied I
| call "Age" and for which I want to calculate the age of the Contact.
| As the initial value of this field, I use the formula:
| =DateDiff("y",[Birthday], Now())
| [ie, I want to display a positive value for the difference in years
| between the current year and the Birthday year]
| which does not give an answer. I have tried several other formulas
| without success.
| Does anyone have a solution to this? Thank you very much.
 
F

FRB

Pat,
Thank you very much for your continued support and interest and for the
references. I am sure you will like the next thread by Milly Staples,
MVP-Outlook, who hits a bull's eye.
Thank you again.
FRB

Pat Garard said:
G'Day again FRB,

Please try:
=DateDiff("yyyy",[Birthday], Now)
We're definitely on the right track.

I have located down a reference:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctdatediff.asp
for the vbScript DateDiff function.

"yyyy" is definitely the go for Years.

Near the very bottom of the page, just before the example, you will find:
"When comparing December 31 to January 1 of the immediately
succeeding year, DateDiff for Year ("yyyy") returns 1 even though
only a day has elapsed."
This was the basis for the doubt - I think you may have to create a
function to calculate the Years of Age correctly.
--
Regards,
Pat Garard
Melbourne, Australia
_______________________

FRB said:
G'Day to you Pat,
Unfortunately, changing the formula
=DateDiff("y",[Birthday], Now())
to
=DateDiff("yyyy",[Birthday], Now())
gives the following error message: "Error in Initial Value formula for
"Age" -- Missing operand before comma, ), or operator."
Thanks for trying.
FRB


Pat Garard said:
G'Day FRB,

1. In DateDiff and DateAdd, 'y' is the format for 'Day of Year' -
you need 'yyyy' for years:
=DateDiff("yyyy",[Birthday], Now())

2. I haven't tried it, but it may also help to format:
=Format(DateDiff("y",[Birthday], Now()),'y')

3. I have a sneaky feeling that this still MAY not correctly give
the age in years - but I could be wrong.
--
Regards,
Pat Garard
Melbourne, Australia
_______________________

I use a custom Contact form in which I want to use a custom fied I call
"Age"
and for which I want to calculate the age of the Contact. As the
initial
value of this field, I use the formula:
=DateDiff("y",[Birthday], Now())
[ie, I want to display a positive value for the difference in years
between
the current year and the Birthday year]
which does not give an answer. I have tried several other formulas
without
success.
Does anyone have a solution to this? Thank you very much.
 
F

FRB

Milly,
Bull's eye hit, right on the nose. Thank you very much. It works.
You are truly an MVP - Outlook.
Merci!
FRB
 
R

rayswchiu

i'd prefer to use the following:

int((Date()-[Birthday])/365)

rayswchiu

--
Phone: (852) 9258 6600
Email: (e-mail address removed)
Pat Garard said:
G'Day FRB,

1. In DateDiff and DateAdd, 'y' is the format for 'Day of Year' -
you need 'yyyy' for years:
=DateDiff("yyyy",[Birthday], Now())

2. I haven't tried it, but it may also help to format:
=Format(DateDiff("y",[Birthday], Now()),'y')

3. I have a sneaky feeling that this still MAY not correctly give
the age in years - but I could be wrong.
--
Regards,
Pat Garard
Melbourne, Australia
_______________________

FRB said:
I use a custom Contact form in which I want to use a custom fied I call
"Age"
and for which I want to calculate the age of the Contact. As the initial
value of this field, I use the formula:
=DateDiff("y",[Birthday], Now())
[ie, I want to display a positive value for the difference in years
between
the current year and the Birthday year]
which does not give an answer. I have tried several other formulas
without
success.
Does anyone have a solution to this? Thank you very much.
 

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