maggielady
Technical User
If I have a date in this format: 29-Jan-95, how do I get that into a string format of yyyymmdd?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
CREATE TABLE D:\TEMP\Date_Conv (Interdate C(9))
INSERT INTO Date_Conv (Interdate) VALUES ('25-Jan-95')
INSERT INTO Date_Conv (Interdate) VALUES ('02-Mar-04')
INSERT INTO Date_Conv (Interdate) VALUES ('12-Sep-00')
yr_Roll=50
DIMENSION aMon(12)
aMon( 1)="JAN"
aMon( 2)="FEB"
aMon( 3)="MAR"
aMon( 4)="APR"
aMon( 5)="MAY"
aMon( 6)="JUN"
aMon( 7)="JUL"
aMon( 8)="AUG"
aMon( 9)="SEP"
aMon(10)="OCT"
aMon(11)="NOV"
aMon(12)="DEC"
SELECT IIF(VAL(RIGHT(Interdate,2))>=yr_Roll, ;
'19'+RIGHT(Interdate,2), ;
'20'+ RIGHT(Interdate,2)) + ;
RIGHT('0'+ALLTRIM(STR(ASCAN(aMon, ;
UPPER(SUBSTR(Interdate,4,3))))), 2) + ;
LEFT(Interdate,2) AS new_date ;
FROM Date_Conv ;
INTO CURSOR conv_date
CREATE TABLE D:\TEMP\Date_Conv (Interdate C(9))
INSERT INTO Date_Conv (Interdate) VALUES ('25-Jan-95')
INSERT INTO Date_Conv (Interdate) VALUES ('02-Mar-04')
INSERT INTO Date_Conv (Interdate) VALUES ('12-Sep-00')
yr_Roll=50
DIMENSION aMon(12)
FOR i=1 TO 12
aMon(i)=UPPER(LEFT(CMON(DATE(2000,i,1)),3))
NEXT
SELECT DTOS(DATE(IIF(VAL(RIGHT(Interdate,2))>=yr_Roll, ;
1900+VAL(RIGHT(Interdate,2)), ;
2000+VAL(RIGHT(Interdate,2))), ;
ASCAN(aMon, UPPER(SUBSTR(Interdate,4,3))), ;
VAL(LEFT(Interdate,2)))) AS new_date ;
FROM Date_Conv ;
INTO CURSOR conv_date