Solved

Retro Y2K failure.

Posted on 2002-06-05
7
248 Views
Last Modified: 2010-04-04
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
Comment
Question by:dpnd88
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 27

Accepted Solution

by:
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

by:Greg Rowland
ID: 7057187
Is the data bad when read in?

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

Examples;


wwTable1.FieldByName('DATE_RECEIVED').Text := FormatDateTime('mm/dd/yyyy', StrToDate(MaskEdit1.Text));

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

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

0
 
LVL 6

Expert Comment

by:wimmeyvaert
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:dpnd88
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

by:kretzschmar
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

by:dpnd88
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

by:kretzschmar
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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

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

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

Join & Ask a Question