Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing the year in a date field

Status
Not open for further replies.

blumash

Programmer
Oct 2, 2003
50
HU
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 ???

Thank's
 
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.

Good Luck,
JRB-Bldr
 
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.

dbMark
 
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 Or get the code that was published in 1998/1999 in FoxPro Advisor Magazine and fix it yourself. I believe it's available on their website
(Do a Search on Y2K - unfortunately to read the good articles and get the code, you'll need to subscribe!)

Rick
 
Thank u all for your help , I solved the problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top