Latly I changed a date field by putting 'SET CENTURY ON', the year in this field changed from 04 to 1904 instead of 2004 , how can I change the year in the field to be 2004 ???
Is the 1904 value coming from values previously stored in a data table or is it a value that you are setting into a memory variable and then displaying on screen?
If it is coming from previously stored data table field values, USE the table and change the DATE field values as necessary.
Something like the following should move all date values up 100 years..
Code:
USE MyTable IN 0
SELECT MyTable
REPLACE ALL DATEFLD WITH GOMONTH(DATEFLD, 12*100) FOR YEAR(DATEFLD) < 1990 && Randomly picked 1990 year
Values stored from this point forward (after the SET CENTURY ON was added) should have the proper year.
If it is coming from a value you set as a Default Value, change your default by specifying the appropriate year.
The reason you see "1904" when the date field was expanded is that the older FoxPro programs defaulted the century to the 1900s. It did not know to pick up the correct century when the short 2-digit form was typed into any entry screen. That's why some sort of code is needed to handle that issue.
Just remember that it isn't "guessing" that 04 is 1904, that's what's actually stored in the data table. It was pretty critical that as of 2000 that ALL data fields in FPD and FPW allowed four digits for the year and SET CENTURY was ON. The only alternatives were to use a third party product like Y2KFOX - at
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.