Calculating age problem

G

ghost

Greeting,
I am trying to calculate the date different between two date with format
ddmmyy to show the age and I am using the following function in unbounded
textbox:
=DateDiff("yyyy", [Birthdate], Now())+ Int( Format(now(), "mmdd") < Format(
[Birthdate], "mmdd") )

When I put the above code in the sources control of the text box , there is
a syntax error
Can any body help me please?
 
J

Jeff Boyce

Since we're not there, it might help to know what the error message says ...
"there is a syntax error" can cover a lot of issues...

(By the way, your expression seems to be trying to compare a value with
another ... won't that return T/F? Also, try matching up your left & right
parentheses...)

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
G

ghost

Here is the msg:
"The expression you entered contains invalid syntax.

You omitted an operand of operator, you entered an invalid character or
comma, or you entered text without surrounding it in quotation marks."


Jeff Boyce said:
Since we're not there, it might help to know what the error message says ...
"there is a syntax error" can cover a lot of issues...

(By the way, your expression seems to be trying to compare a value with
another ... won't that return T/F? Also, try matching up your left & right
parentheses...)

Regards

Jeff Boyce
Microsoft Office/Access MVP

ghost said:
Greeting,
I am trying to calculate the date different between two date with format
ddmmyy to show the age and I am using the following function in unbounded
textbox:
=DateDiff("yyyy", [Birthdate], Now())+ Int( Format(now(), "mmdd") <
Format(
[Birthdate], "mmdd") )

When I put the above code in the sources control of the text box , there
is
a syntax error
Can any body help me please?
 
B

BruceM

I was going to refer the OP to the age functions on the MVP web site, but
when I went there to get the address I found the exact same function the OP
used. After puzzling over it for a while and checking the components of the
expression I figured out that Int converts True or False to -1 or 0. If the
birth date has not arrived, 1 is subtracted from (i.e. -1 is added to); the
years determined by DateDiff; otherwise 0 is added.
I have not been able to reproduce the OP's problem.
To the OP, what happens when you use a specific date? For example:
=DateDiff("yyyy",#7/4/1976#,Now())+Int(Format(Now(),"mmdd")<Format(#7/4/1976#,"mmdd"))
I was assuming you received a specifc message that there is a syntax error
in the expression, but as Jeff asked, what was the actual error or message?

Jeff Boyce said:
Since we're not there, it might help to know what the error message says
... "there is a syntax error" can cover a lot of issues...

(By the way, your expression seems to be trying to compare a value with
another ... won't that return T/F? Also, try matching up your left &
right parentheses...)

Regards

Jeff Boyce
Microsoft Office/Access MVP

ghost said:
Greeting,
I am trying to calculate the date different between two date with format
ddmmyy to show the age and I am using the following function in unbounded
textbox:
=DateDiff("yyyy", [Birthdate], Now())+ Int( Format(now(), "mmdd") <
Format(
[Birthdate], "mmdd") )

When I put the above code in the sources control of the text box , there
is
a syntax error
Can any body help me please?
 
G

ghost

Already posted, please see previous post

BruceM said:
I was going to refer the OP to the age functions on the MVP web site, but
when I went there to get the address I found the exact same function the OP
used. After puzzling over it for a while and checking the components of the
expression I figured out that Int converts True or False to -1 or 0. If the
birth date has not arrived, 1 is subtracted from (i.e. -1 is added to); the
years determined by DateDiff; otherwise 0 is added.
I have not been able to reproduce the OP's problem.
To the OP, what happens when you use a specific date? For example:
=DateDiff("yyyy",#7/4/1976#,Now())+Int(Format(Now(),"mmdd")<Format(#7/4/1976#,"mmdd"))
I was assuming you received a specifc message that there is a syntax error
in the expression, but as Jeff asked, what was the actual error or message?

Jeff Boyce said:
Since we're not there, it might help to know what the error message says
... "there is a syntax error" can cover a lot of issues...

(By the way, your expression seems to be trying to compare a value with
another ... won't that return T/F? Also, try matching up your left &
right parentheses...)

Regards

Jeff Boyce
Microsoft Office/Access MVP

ghost said:
Greeting,
I am trying to calculate the date different between two date with format
ddmmyy to show the age and I am using the following function in unbounded
textbox:
=DateDiff("yyyy", [Birthdate], Now())+ Int( Format(now(), "mmdd") <
Format(
[Birthdate], "mmdd") )

When I put the above code in the sources control of the text box , there
is
a syntax error
Can any body help me please?
 
B

BruceM

Yup, I saw that, but what happens when you use a literal date as suggested?
Another thing to try is creating a new text box and typing the entire
expression from scratch. Or maybe a compact and repair will shake something
loose. As I said, it should work. It seems that something we can't see is
preventing it.

ghost said:
Already posted, please see previous post

BruceM said:
I was going to refer the OP to the age functions on the MVP web site, but
when I went there to get the address I found the exact same function the
OP
used. After puzzling over it for a while and checking the components of
the
expression I figured out that Int converts True or False to -1 or 0. If
the
birth date has not arrived, 1 is subtracted from (i.e. -1 is added to);
the
years determined by DateDiff; otherwise 0 is added.
I have not been able to reproduce the OP's problem.
To the OP, what happens when you use a specific date? For example:
=DateDiff("yyyy",#7/4/1976#,Now())+Int(Format(Now(),"mmdd")<Format(#7/4/1976#,"mmdd"))
I was assuming you received a specifc message that there is a syntax
error
in the expression, but as Jeff asked, what was the actual error or
message?

Jeff Boyce said:
Since we're not there, it might help to know what the error message
says
... "there is a syntax error" can cover a lot of issues...

(By the way, your expression seems to be trying to compare a value with
another ... won't that return T/F? Also, try matching up your left &
right parentheses...)

Regards

Jeff Boyce
Microsoft Office/Access MVP


Greeting,
I am trying to calculate the date different between two date with
format
ddmmyy to show the age and I am using the following function in
unbounded
textbox:
=DateDiff("yyyy", [Birthdate], Now())+ Int( Format(now(), "mmdd") <
Format(
[Birthdate], "mmdd") )

When I put the above code in the sources control of the text box ,
there
is
a syntax error
Can any body help me please?
 
J

John W. Vinson

Greeting,
I am trying to calculate the date different between two date with format
ddmmyy

Is this a Date/Time field (in which case the format is irrelevant)? or a Text
or Number field that you (but not Access!!!) consider to represent a date? If
it's not a Date/Time field you will need an additional step to convert it to
one.
to show the age and I am using the following function in unbounded
textbox:
=DateDiff("yyyy", [Birthdate], Now())+ Int( Format(now(), "mmdd") < Format(
[Birthdate], "mmdd") )

To avoid the possible problems with the interpretation of True or False as a
number, I'd use

=DateDiff("yyyy", [Birthdate], Date())-IIF(Format(Date(), "mmdd") < Format(
[Birthdate], "mmdd"), 1, 0)
 
G

ghost

Thank you BruceM, but the problems still as it is

BruceM said:
Yup, I saw that, but what happens when you use a literal date as suggested?
Another thing to try is creating a new text box and typing the entire
expression from scratch. Or maybe a compact and repair will shake something
loose. As I said, it should work. It seems that something we can't see is
preventing it.

ghost said:
Already posted, please see previous post

BruceM said:
I was going to refer the OP to the age functions on the MVP web site, but
when I went there to get the address I found the exact same function the
OP
used. After puzzling over it for a while and checking the components of
the
expression I figured out that Int converts True or False to -1 or 0. If
the
birth date has not arrived, 1 is subtracted from (i.e. -1 is added to);
the
years determined by DateDiff; otherwise 0 is added.
I have not been able to reproduce the OP's problem.
To the OP, what happens when you use a specific date? For example:
=DateDiff("yyyy",#7/4/1976#,Now())+Int(Format(Now(),"mmdd")<Format(#7/4/1976#,"mmdd"))
I was assuming you received a specifc message that there is a syntax
error
in the expression, but as Jeff asked, what was the actual error or
message?

Since we're not there, it might help to know what the error message
says
... "there is a syntax error" can cover a lot of issues...

(By the way, your expression seems to be trying to compare a value with
another ... won't that return T/F? Also, try matching up your left &
right parentheses...)

Regards

Jeff Boyce
Microsoft Office/Access MVP


Greeting,
I am trying to calculate the date different between two date with
format
ddmmyy to show the age and I am using the following function in
unbounded
textbox:
=DateDiff("yyyy", [Birthdate], Now())+ Int( Format(now(), "mmdd") <
Format(
[Birthdate], "mmdd") )

When I put the above code in the sources control of the text box ,
there
is
a syntax error
Can any body help me please?
 
B

BruceM

If you tried everything I suggested and still are not getting the desired
results, try using the literal date expression I suggested in a new
database. If still no luck then the only remaining explanation seems to be
that there is a problem with your installation of Access.

ghost said:
Thank you BruceM, but the problems still as it is

BruceM said:
Yup, I saw that, but what happens when you use a literal date as
suggested?
Another thing to try is creating a new text box and typing the entire
expression from scratch. Or maybe a compact and repair will shake
something
loose. As I said, it should work. It seems that something we can't see
is
preventing it.

ghost said:
Already posted, please see previous post

:

I was going to refer the OP to the age functions on the MVP web site,
but
when I went there to get the address I found the exact same function
the
OP
used. After puzzling over it for a while and checking the components
of
the
expression I figured out that Int converts True or False to -1 or 0.
If
the
birth date has not arrived, 1 is subtracted from (i.e. -1 is added
to);
the
years determined by DateDiff; otherwise 0 is added.
I have not been able to reproduce the OP's problem.
To the OP, what happens when you use a specific date? For example:
=DateDiff("yyyy",#7/4/1976#,Now())+Int(Format(Now(),"mmdd")<Format(#7/4/1976#,"mmdd"))
I was assuming you received a specifc message that there is a syntax
error
in the expression, but as Jeff asked, what was the actual error or
message?

Since we're not there, it might help to know what the error message
says
... "there is a syntax error" can cover a lot of issues...

(By the way, your expression seems to be trying to compare a value
with
another ... won't that return T/F? Also, try matching up your left
&
right parentheses...)

Regards

Jeff Boyce
Microsoft Office/Access MVP


Greeting,
I am trying to calculate the date different between two date with
format
ddmmyy to show the age and I am using the following function in
unbounded
textbox:
=DateDiff("yyyy", [Birthdate], Now())+ Int( Format(now(), "mmdd") <
Format(
[Birthdate], "mmdd") )

When I put the above code in the sources control of the text box ,
there
is
a syntax error
Can any body help me please?
 

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