General discussion

Locked

Replacing the year within a date field

By abcs ·
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

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Replacing the year within a date field

by Don Christner In reply to Replacing the year within ...

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

Collapse -

Replacing the year within a date field

by abcs In reply to Replacing the year within ...

Poster rated this answer

Collapse -

Replacing the year within a date field

by abcs In reply to Replacing the year within ...

This question was closed by the author

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Forums