dbTalk Databases Forums  

Re: Foxbase replace command

comp.databases.xbase.fox comp.databases.xbase.fox


Discuss Re: Foxbase replace command in the comp.databases.xbase.fox forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Rick Bean
 
Posts: n/a

Default Re: Foxbase replace command - 10-14-2003 , 07:55 AM






Pradeep,
In a replace, the "with" value must match the type of field you are replacing into. First, Year() requires a date type not a character string ('2002'). Since PJDATE is a date and Year() returns a numeric, that also won't work.
Since I no longer have FoxBase available, I can only give you an appropriate Visual FoxPro syntax:
REPLACE ALL PJDATE with date(2002, month(PJDATE), day(PJDATE)) ;
for year(PJDATE) =1902

Assuming the date format is currently MMDDYYYY, this should work in FoxPro 2.x:
REPLACE ALL PJDATE with ctod(str(month(PJDATE),2)+"/"+str(day(PJDATE)),2)+"/"+"2002") ;
for year(PJDATE) =1902

Rick

"mspradeep78" <mspradeep78 (AT) yahoo (DOT) com> wrote

Quote:
Hi





Some body help with this command



REPLACE ALL PJDATE with CTOD('2/09/2002') for PJDATE =CTOD('2/09/1902')





PJDATE is my date field



The above command works perfectly allright and a single record is
replaced . I have to change all the records where year = 1902 to
year 2002.



I tried this command

REPLACE ALL PJDATE with YEAR('2002') for PJDATE =YEAR('1902')



It says invalid argument



I have thousands of records to be changed .





Help regarding this query will be highly appreciated



Thanks

Pradeep


--
M.S.Pradeep


Posted via http://dbforums.com

Reply With Quote
  #2  
Old   
Dan Freeman
 
Posts: n/a

Default Re: Foxbase replace command - 10-14-2003 , 10:43 AM






Did you SELECT PJDATE before your replace? The ALL will be evaluated in the
currently selected workarea. If the currently selected workarea has no
relation into PJDATE, only one record, the current record, will be affected.

Dan

"mspradeep78" <mspradeep78 (AT) yahoo (DOT) com> wrote

Quote:
Hi





Some body help with this command



REPLACE ALL PJDATE with CTOD('2/09/2002') for PJDATE =CTOD('2/09/1902')





PJDATE is my date field



The above command works perfectly allright and a single record is
replaced . I have to change all the records where year = 1902 to
year 2002.



I tried this command

REPLACE ALL PJDATE with YEAR('2002') for PJDATE =YEAR('1902')



It says invalid argument



I have thousands of records to be changed .





Help regarding this query will be highly appreciated



Thanks

Pradeep


--
M.S.Pradeep


Posted via http://dbforums.com



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.