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

How to convert num to Char

Status
Not open for further replies.

iren

Technical User
Mar 8, 2005
106
US
Hi everybody,

I need to convert Num type of field process_YYYYMM (for example 200508) into character in order to cut off the month part and get process_yyyy for ex 2005 (I assume it can be done by substr().
Proc contents shows that Process Yyyymm field is numeric:
*******************************************************
variable Type Len Pos FormatInformatLabel Process_Yyyymm Num 8 32 Process Yyyymm

***************************************************
After that I have to convert it back to num in order to use this field as count(distinct process_Yyyy) in code

How can I implement this code?
Thank you in advance

Iren

 
Irin,
You could do some fancy format and datepart functions, but if all you want is the month part of this 'numeric' var try this.
Code:
monthpart = substr(trim(left(put(process_YYYYMM, 8.))),5);

This should give the month number.

I hope that this helps you,
Klaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top