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

convert table from number to date

Status
Not open for further replies.

coachvi

Technical User
Nov 19, 2008
111
GH
I have a column which is holding data like 20100630. I want to convert this like 01/10/30 or 01/2010/30 or Jan 2010 or any date format. Anyone has any clue.

this is what i ve done

stringvar MyDate:=totext({APVEN.DATELASTPA},0,"yyyymmdd");
cdate(val(left(MyDate,4)),val(mid(MyDate,5,2)),1)

getting error a month number be between 1 and 12
 
Alternatively if for some reason you don't want to use pwformatdate, this works

StringVar MyDate := ToText({APVEN.DATELASTPA}, 0, '');

NumberVar MyDate_year := 0;
NumberVar MyDate_month := 0;
NumberVar MyDate_day := 0;

if (Length(MyDate)=8) then
MyDate_year := ToNumber( MyDate[1 to 4] );
MyDate_month := ToNumber( MyDate[5 to 6] );
MyDate_day := ToNumber( MyDate[7 to 8] );

Date( MyDate_year, MyDate_month, MyDate_day )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top