Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Y2k Bug in all flavours of FoxPro
Message
From
09/05/1998 15:10:59
Ryan Hirschey
Federal Reserve Bank of New York
New York City, New York, United States
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00098306
Message ID:
00098309
Views:
31
>Hi,
>
>I have just recently discovered a bug in all version of FoxPro including VFP 5. If you turn century on and type a date in an empty date field with only two digits for year and press enter, then always the 19 is added to the two digit year you entered, no matter what date is set in your PC.
>
>For example if I type 01/01/98 then it will be converted to 01/01/1998 even if your system date is 05/04/2001 !!
>
>I mean shouldn't it be converted to 01/01/2098
>
>I have even try to hook the Valid event but the value you get when you get control in the Valid event is 01/01/1998
>
>What is the opinion of you peoples, is it going to be solved in VFP 6 or do we nerds have to make some workarounds?
>
>Regards,
>
>Shahbaz Ahmer

The SET CENTURY ON | OFF | TO [nCentury [ROLLOVER nYear]] command will give you what you are looking for. You should be able to code the command to figure out the century based on the DATE() function. That way, no matter what century your system date is set to, it will always put in the desired century, without changing your command.

This should work:
SET CENTURY TO VAL(LEFT(DTOC(DATE(),1),2))

To test it out:
1. Change your system date to 20xx
2. Type the following into your command window

SET CENTURY TO VAL(LEFT(DTOC(DATE(),1),2))
? {02/16/56} && Displays 02/16/2056

3. Change your system date back to 19xx
4. Type the following into your command window

SET CENTURY TO VAL(LEFT(DTOC(DATE(),1),2))
? {02/16/56} && Displays 02/16/1956

Hope this helps.
Ryan Hirschey
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform