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

Very urgent!!!!ctod in foxpro

Status
Not open for further replies.

Nithya

Technical User
Jul 18, 2001
15
PH
hi
how to convert a character field in foxpro containing values like '19691231' to a date field in oracle which should be of the form '31-dec-1969' via a text file?the character field in foxpro needs to be converted to date in the format of date in oracle and then put in the text file.
Can ctod function in foxpro be used for this purpose?if yes,what is the argument that needs to be passed to ctod function?
Thanks in advance
Nithya
 
All FoxPro String to Date convertions routines need a seperator to act on.
so step 1 would be to add them
lcDate = "19691231"
lddate = ctod(substr(lcDate,1,4)+"/"+substr(lcdate,5,2)+"/"+substr(lcdate,7,2))

step 2 would be to convert it to whay you need
lcDate = alltrim(str(day(lddate)))+"-"+Substr(cmonth(lddate),1,3)+"-"+alltrim(str(year(lddate))) David W. Grewe
Dave@internationalbid.com
 
Hi;

This should work for you:

SET CENTURY ON

* Input Date
lcdate = '19691231'

* Break date down to mm,dd,yyyy
lcyyyy = LEFT(lcdate,4)
lcmm = SUBSTR(lcdate,5,2)
lcdd = RIGHT(lcdate,2)

* Re-assemble date to mm/dd/yyyy
lcdate = lcmm+'/'+lcdd+'/'+lcyyyy

* Extract First 3 Characters of Month name
lcmonth = UPPER(LEFT(CMONTH(CTOD(lcdate)),3))

* Build Output field

lcdateout = lcdd + '-' + lcmonth + '-' + lcyyyy



Ed Please let me know if the sugestion(s) I provide are helpful to you.
Sometimes your the windshield... Sometimes your the bug.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top