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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

expanding the year field to 4 chr. 1

Status
Not open for further replies.

jackie1948

Programmer
Jan 25, 2002
78
US
I have 2 tables, tabl-1 has a yrfield as XXXX, tabl-2 has a yrfield as XX. I appended tabl-2 into tabl-1. My question is how do I get the year field in tabl-2 to be 4 chr.
 

set filter to substr(yrfield,2,2)=space(2)
replace all yrfield with left(yrfield,2)+iif(val(yrfield)<3,&quot;20&quot;,&quot;19&quot;)+substr(yrfield,1,2)
set filter to
 
you will have to do a work around.

select ' '+yrfield from tabl-2 into array temp

select tabl-1
append from array temp

this will pad the field with two blank charcters.
if you need to put the century just change to suit. if the century is all 19 find, otherwise do it with a whare clause and do one for each century. Attitude is Everything
 
HI Jackie1948,

If the year field is a character field... then
REPLACE ALL yrField WITH ;
IIF(VAL(yrfield)<3,&quot;20&quot;,&quot;19&quot;)+ALLT(STR(yrField)) ;
FOR LEN(ALLT(yrField)) = 2

If the year field is a numeric field... then

REPLACE ALL yrFiled WITH 1900+yrFiled ;
FOR BETWEEN(yrField,04,99)
REPLACE ALL yrFiled WITH 2000+yrFiled ;
FOR BETWEEN(yrField,01,03)

It is assumed that there are no years below 1904 and no years after 2003. Suitably change otherwise.

Hope this helps :)

ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Ramani,
i agree with you, but last between try
FOR BETWEEN(yrField,00,03)
to replace added year 2000 too...(it is orphan,stay 0)
Tesar
(excuse my triviality..)
 
Thanks alot, you guys have helped me out so many times. I am so thankful that we have a site like this to help us out when we are having programming problems. There is not a manuel out there that can compare to the help we can get at tek-tips.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top