473,322 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

datediff question

i have a question regarding the DateDiff function. I am quite new to access
and seem to have hit a snag with this function. My problem is as follows:

I have a table field that list a persons DateOfBirth. The standard format
for this field is yy.mm.dd (ie- 73.02.01). And on the form that the field is
brought into the input mask for the field is 00.99.99;0;_

What i want to do is have another field on the form that generates the
persons Age. Now, i checked out Microsofts website and they list an example
that makes the Birthdate filed be set to Short Date and for the Age field to
have the following control source:
=DateDiff("yyyy", [Birthdate], Now())+ Int( Format(now(), "mmdd") <
Format( [Birthdate], "mmdd") )

Now, this will generate a number but the only problem
is that for a birthdate of 73.02.01 it will display 31, but for a
birthdate of 28.03.02 it will generate a negative number.

How can I rectify this problem? Your input is appreciated.


Nov 13 '05 #1
3 1914
"chanchito_cojones" <po******@noemail.net> wrote in
news:uy*********************@twister01.bloor.is.ne t.cable.rogers.
com:
i have a question regarding the DateDiff function. I am quite
new to access and seem to have hit a snag with this function.
My problem is as follows:

I have a table field that list a persons DateOfBirth. The
standard format for this field is yy.mm.dd (ie- 73.02.01). And
on the form that the field is brought into the input mask for
the field is 00.99.99;0;_

What i want to do is have another field on the form that
generates the persons Age. Now, i checked out Microsofts
website and they list an example that makes the Birthdate
filed be set to Short Date and for the Age field to have the
following control source: =DateDiff("yyyy", [Birthdate],
Now())+ Int( Format(now(), "mmdd") < Format( [Birthdate],
"mmdd") )

Now, this will generate a number but the only problem
is that for a birthdate of 73.02.01 it will display 31, but
for a birthdate of 28.03.02 it will generate a negative
number.

How can I rectify this problem? Your input is appreciated.

If the negative number is 24, the problem is one of Access
automatically (mis)setting the century.
Set the input mask of the birthdate field to be 9999.99.99 so
that you can force the correct century.

Access seems to think that two digit years <30 belong in the 21st
century, and >-30 belong in the old millenium.

Bob Quintal
Nov 13 '05 #2
Thanks bob. I appreciate the help. Let me just verify that I understand what
you are saying. Pretty much there is no way I would be able to use the Age
function with a 2digit version of the Year. It has to be in the complete
four digits or it won't work. Correct? Because if so that would really
suck. hehe. Oh well.

thanks again.
"Bob Quintal" <bq******@generation.net> wrote in message
news:76******************************@news.teranew s.com...
"chanchito_cojones" <po******@noemail.net> wrote in
news:uy*********************@twister01.bloor.is.ne t.cable.rogers.
com:
i have a question regarding the DateDiff function. I am quite
new to access and seem to have hit a snag with this function.
My problem is as follows:

I have a table field that list a persons DateOfBirth. The
standard format for this field is yy.mm.dd (ie- 73.02.01). And
on the form that the field is brought into the input mask for
the field is 00.99.99;0;_

What i want to do is have another field on the form that
generates the persons Age. Now, i checked out Microsofts
website and they list an example that makes the Birthdate
filed be set to Short Date and for the Age field to have the
following control source: =DateDiff("yyyy", [Birthdate],
Now())+ Int( Format(now(), "mmdd") < Format( [Birthdate],
"mmdd") )

Now, this will generate a number but the only problem
is that for a birthdate of 73.02.01 it will display 31, but
for a birthdate of 28.03.02 it will generate a negative
number.

How can I rectify this problem? Your input is appreciated.

If the negative number is 24, the problem is one of Access
automatically (mis)setting the century.
Set the input mask of the birthdate field to be 9999.99.99 so
that you can force the correct century.

Access seems to think that two digit years <30 belong in the 21st
century, and >-30 belong in the old millenium.

Bob Quintal

Nov 13 '05 #3
"chanchito_cojones" <po******@noemail.net> wrote in
news:NG*********************@twister01.bloor.is.ne t.cable.rogers.
com:
Thanks bob. I appreciate the help. Let me just verify that I
understand what you are saying. Pretty much there is no way I
would be able to use the Age function with a 2digit version of
the Year. It has to be in the complete four digits or it won't
work. Correct? Because if so that would really suck. hehe. Oh
well.

thanks again.

You could work around the problem by testing if the birthdate is
future, and subtract 100 years. That will work until you enter
the birthdate of someone who is 201 years old. [:^?

Or test if age <0, then age = age+100

Bob Quintal

"Bob Quintal" <bq******@generation.net> wrote in message
news:76******************************@news.teranew s.com...
"chanchito_cojones" <po******@noemail.net> wrote in
news:uy*********************@twister01.bloor.is.ne t.cable.roge
rs. com:
> i have a question regarding the DateDiff function. I am
> quite new to access and seem to have hit a snag with this
> function. My problem is as follows:
>
> I have a table field that list a persons DateOfBirth. The
> standard format for this field is yy.mm.dd (ie- 73.02.01).
> And on the form that the field is brought into the input
> mask for the field is 00.99.99;0;_
>
> What i want to do is have another field on the form that
> generates the persons Age. Now, i checked out Microsofts
> website and they list an example that makes the Birthdate
> filed be set to Short Date and for the Age field to have
> the following control source: =DateDiff("yyyy",
> [Birthdate], Now())+ Int( Format(now(), "mmdd") < Format(
> [Birthdate], "mmdd") )
>
> Now, this will generate a number but the only problem
> is that for a birthdate of 73.02.01 it will display 31, but
> for a birthdate of 28.03.02 it will generate a negative
> number.
>
> How can I rectify this problem? Your input is appreciated.
>

If the negative number is 24, the problem is one of Access
automatically (mis)setting the century.
Set the input mask of the birthdate field to be 9999.99.99 so
that you can force the correct century.

Access seems to think that two digit years <30 belong in the
21st century, and >-30 belong in the old millenium.

Bob Quintal



Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Drago | last post by:
Hi, I got the next question, I want to know the diference between two dates and thats is really easy, but my problem is get that diference in the following format ex. "the diference is= 0 year,...
8
by: inamori | last post by:
I face that problems 07/01/2003 06/30/2006 ---------> it should be 3 01/01/2003 02/28/2005 --------->could i get 2 years and 2 months 01/01/2003 03/01/2005 ...
1
by: intl04 | last post by:
I'm trying to set up a query that will include a new field ('Days until completion') whose value is derived from the DateDiff function. I think I have the syntax correct but am not sure. Days...
4
by: Paolo | last post by:
I am having some problem with a Year Function. I have form on which I have 4 field which indicate dates and an additional form which sums those dates: These are the fields: YEARS...
3
by: T23Ij9 | last post by:
Hi. I have 3 seperate date fields. InitialDate InspDate ReportDate I am trying to setup several unbound Text boxes in a form that will give me days elapsed between these dates. These text...
5
by: mcbill20 | last post by:
Hello all. I have a really basic question that I hope someone has a better answer for. I apologize in advance-- I know this is probably a really basic question but I am used to Oracle rathern than...
7
by: Adrian | last post by:
I hit on this problem converting a VB.NET insurance application to C#. Age next birthday calculated from date of birth is often needed in insurance premium calculations. Originally done using...
4
by: Brita | last post by:
You guys have been life savers for me, and I appreciate your help so much. I am trying to check the difference in days between two submitted requests. DateFormat df =...
14
by: cmdolcet69 | last post by:
I'm trying to use the DateDiff function to calculate the difference whether a shift has been setup. when i run the code below with strFirstShiftEnd as a stringor date or datetime. I get an error...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.