?
Solved

Retro Y2K failure.

Posted on 2002-06-05
7
Medium Priority
?
249 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
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses

770 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