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

Date Conversion from character field 1

Status
Not open for further replies.

mm0000

IS-IT--Management
May 19, 2002
295
IN
How can I convert a character field with dates in the format 'DD-MON-YY' to a valid Foxpro date.
 
Something like this procedure? :

LOCAL ldDate

ldDate = ConvertDate('12-APR-02')

? DTOC(ldDate)

PROCEDURE ConvertDate
LPARAMETER tcDate
LOCAL lcMonTxt, lcMonNum, lcDay, lcYear

lcDay = SUBSTR(ALLTRIM(tcDate), 1, 2)
lcMon = SUBSTR(ALLTRIM(tcDate), 4, 3)
lcYear = SUBSTR(ALLTRIM(tcDate), 8, 2)

DO CASE

CASE lcMon = 'JAN'
lcMon = '01'

CASE lcMon = 'FEB'
lcMon = '02'

CASE lcMon = 'MAR'
lcMon = '03'

CASE lcMon = 'APR'
lcMon = '04'

CASE lcMon = 'MAY'
lcMon = '05'

CASE lcMon = 'JUN'
lcMon = '06'

CASE lcMon = 'JUL'
lcMon = '07'

CASE lcMon = 'AUG'
lcMon = '08'

CASE lcMon = 'SEP'
lcMon = '09'

CASE lcMon = 'OCT'
lcMon = '10'

CASE lcMon = 'NOV'
lcMon = '11'

CASE lcMon = 'DEC'
lcMon = '12'

ENDCASE

lcNewDate = ALLTRIM(lcDay) + '/' + ALLTRIM(lcMon) + '/' + ALLTRIM(lcYear)

ldDate = CTOD(lcNewDate)

RETURN ldDate

ENDPROC
"I love work. I can sit and stare at it for hours..."
 
Hi Mike!

Yes, I assumed that from the title of the thread ;) "I love work. I can sit and stare at it for hours..."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top