PC Review


Reply
Thread Tools Rate Thread

calculate Age problem date notation european american format

 
 
feorges
Guest
Posts: n/a
 
      13th Apr 2011
Hi,
in a module i want to calculate the age of a person , When a person is less
than 1 year, i will count the months.
My problem is that on user will gives dates in european format (dd-MM-yyyy)
and the code alwayes calculate in american notation with a mismatch as
result. A person which is born on 05-01-2010 (dd-MM-YYYY) will be born in
code on the first of mai (MM-dd-yyyy). in this example the peron is must one
year and 3 months, in code he wil be less than one year and he is only 11
months old.
How i can solve this problem ?

kindley regards Georges


 
Reply With Quote
 
 
 
 
Bob Barrows
Guest
Posts: n/a
 
      14th Apr 2011
feorges wrote:
> Hi,
> in a module i want to calculate the age of a person , When a person
> is less than 1 year, i will count the months.
> My problem is that on user will gives dates in european format
> (dd-MM-yyyy) and the code alwayes calculate in american notation with
> a mismatch as result. A person which is born on 05-01-2010
> (dd-MM-YYYY) will be born in code on the first of mai (MM-dd-yyyy).
> in this example the peron is must one year and 3 months, in code he
> wil be less than one year and he is only 11 months old.
> How i can solve this problem ?
>

Use a calendar control for date entry and store the dates in a date/time
column rather than a text column.


 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      14th Apr 2011
On Wed, 13 Apr 2011 23:05:39 +0200, "feorges" <(E-Mail Removed)> wrote:

>Hi,
>in a module i want to calculate the age of a person , When a person is less
>than 1 year, i will count the months.
>My problem is that on user will gives dates in european format (dd-MM-yyyy)
>and the code alwayes calculate in american notation with a mismatch as
>result. A person which is born on 05-01-2010 (dd-MM-YYYY) will be born in
>code on the first of mai (MM-dd-yyyy). in this example the peron is must one
>year and 3 months, in code he wil be less than one year and he is only 11
>months old.
>How i can solve this problem ?
>
>kindley regards Georges
>


A Date/Time field has no formatting. It's actually stored as a number, a count
of days and fractions of a day since midnight, December 30, 1899.

The code needs to use the DateValue() function to convert the user's input to
a valid Date/Time. DateValue() recognizes the computer's regional date
settings; thus someone whose computer is set to the American m/d/y setting
will see 3/5/2010 as March 5, whereas a computer set to European dates will
see it as May 3.

So just use an expression such as

DateValue([Forms]![yourform]![controlname])

in your age calculation and you should be ok regardless of the user's regional
setting.

However, if you have a computer with its Control Panel... Regional and
Language Settings... Regional set to "English (US)", and the user sitting in
front of it types a date in European order, it will obediently give the wrong
answer. One suggestion is to avoid the ambiguity by either training the users
to use the ISO yyyy-mm-dd format (2011-04-14) or use the month name (Apr 14 or
14 Apr).
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also http://www.utteraccess.com
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert European Date format to American Format =?Utf-8?B?QWxiZXJ0?= Microsoft Excel Misc 3 21st Aug 2007 10:02 PM
how can i change european date format to american =?Utf-8?B?cGNsaWZmb3JkOTk=?= Microsoft Excel Misc 11 28th Nov 2006 02:05 AM
European vs american date notations Paul Microsoft Excel Misc 2 5th Nov 2004 12:24 PM
Converting European format CSV to American Rich Microsoft Excel Misc 1 14th May 2004 07:54 PM
European/American Date Problem Nikki Microsoft Excel Programming 2 8th Mar 2004 11:35 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:06 PM.