Discussion Locked

Replacing the year within a date field

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi to anyone,

I have an old foxpro database with a field defined as follows:
invdte Date 8
When I set century on the year for some records show as 1900, 1901, 1902 etc.
I want to replace the year portion with 2000, 2001, 2002 etc.

I am using the following syntax and it is not working. Help
replace substr(dtoc(invdte),7,4) with "2000"
This does not work on a date field. What am I doing wrong.
TIA
Robert Payne

3 replies

by don christner

Within a loop, I would use:

strDate=dtoc(invdte)
strDate= left(strDate,6)+"20"+right(strDate,2)
replace invdte with ctod(strDate)

Of course, if you wanted you could condense the code into one line, but for clairity, I stretched it out.

Don

This discussion is closed to new replies.