Solved

# Retro Y2K failure.

Posted on 2002-06-05
243 Views
Using a Paradox table in a Delphi program which in part calculates age, dates prior to 1/1/2000 are read as 2001 year.  So someone born in 1995 has an age of -93 years!  The Paradox table is set to fourdigityear = true, yet it is obviously not working as one.  Any answers to how to get it to work right?  Is there a Delphi solution or this a Paradox problem? Is there a Delphi fix to a Paradox problem.
0
Question by:dpnd88

LVL 27

Accepted Solution

kretzschmar earned 100 total points
ID: 7056959
sounds like an y2k-problem,
is your shortdate-setting of your system to four digits?
can you show your calculation routine?
0

LVL 4

Expert Comment

ID: 7057187
Is the data bad when read in?

I have been very successful using FormatDateTime() to force dates to behave.

Examples;

wwTable2.FieldByName('DATE_SENT').Text := FormatDateTime('mm/dd/yyyy', wwDBDateTimePicker1.Date);

myArray[1, 1] := FormatDateTime(' mmmm d, YYYY', Date);

0

LVL 6

Expert Comment

ID: 7058854
Maybe it is not the Paradox-Table,
but only you way of calcuating the Age that results in strange values.

Can you post your code to do the calculations ?

Best regards,

The Mayor.
0

Author Comment

ID: 7059336
The calculations work on dates after 1/1/2000.  That the same mechanism results in the calculations using a 2000 date for a 1900 date tells me it something in the unpublished coding.
Surfer Joe may have the answer by suggesting to format the date before it saved to table.  Let's clarify some things.  I am using two calendars to calculate age by taking the computer numeric date and converting to a string date and then performing math and converting back to a date. Does dateTimePicker offer some internal function for calculating an interval?  Here is the coding I used for calculating the date (which, again, works on post Y2K dates) and saving to table.
dob = date of birth
bd = birthday
td = today's date
dob:= (dbedit8.text);
MonthCalendar4.Date:= StrToDate(dob);
td:= (MonthCalendar3.Date);
bd:= (MonthCalendar4.Date);
Months:= ((td-bd)/30.5);
Edit66.text:= FloatToStrF(Months, ffFixed, 3,1);
years:= (Months/12);
Edit60.text:= FloatToStrF(Years, ffFixed, 3,1);
Age:= Years;
Edit58.text:= FloatToStrF(Age, ffFixed, 3,1);
Edit4.Text:= DateToStr(MonthCalendar3.Date);

Label3.Caption := Format('Current Age: %3.2f years ',[Years]);

then to post the data:
Table11.FieldByName('Date').AsFloat:= strToDate(Edit4.Text);
Table11.FieldByName('months').AsFloat:= strToFloat(Edit66.Text);
Table11.FieldByName('years').AsFloat:= strToFloat(Edit60.Text);
Table11.Post;

So according to Surfer Joe I need to format the first line of data going into the table, the
Table11.FieldByName('Date').AsFloat:= strToDate(Edit4.Text); line, even though the table is supposed to be formated already?  Your code is different than what I am using, the ".Text" vs. the "AsFloat".
I think you have the right answer but I don't understand your context as well as my own. Give a bit of advice on this and you win, Surfer Joe.
0

LVL 27

Expert Comment

ID: 7059372
>Your code is different than what I am using, the ".Text"
>vs. the "AsFloat".

seems to be a typo,

i prefer and recommend for datevalues the AsDateTime-method
rather than AsFloat because the internal Datevalue of
the database may other than the TDateTimeType vs. FloatType

maybe this causes your problem.

btw.
why do you convert the date into a string?
or other why do you use a string-conversion for your calculation if you have the date already?
(you may crash by other regional settings)

meikl ;-)
0

Author Comment

ID: 7063252
Yes, the system shortdate setting was not set properly!  I thought I had that checked but apparently not.  Thank you.
0

LVL 27

Expert Comment

ID: 7063398
glad to helped you :-)

well, if this was the cause,
you do not need to change the systemsettings
(the format is only taken from there during app-init)

just add this lines at appstart
(im formcreate-event of the mainform for example)

shortdateformat := 'mm/dd/yyyy';
dateseparator := '/';

this will change the shortdateinterpetation
for your app only, so it doesn't effect the system
and the app works with this format

meikl ;-)
0

## Join & Write a Comment Already a member? Login.

### Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

#### 743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

#### Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!