Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Retro Y2K failure.

Posted on 2002-06-05
7
Medium Priority
?
250 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 300 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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 Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

636 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