Data Conversion

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
tguthrie226
Participant
Posts: 3
Joined: Tue Mar 25, 2008 9:51 am
Location: Atlanta

Data Conversion

Post by tguthrie226 »

How do I take an internal InfoLease system date and convert it to MMDDYYYY without the / showing up? I am getting MM/DD/YYYY.

I have tried individual conversions on the date field with DM[2] DD[2] and DY[4], I have tried "DMDY[2,2,4], and I have tried MDY with no success.

Thanks.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Welcome Aboard,
What is your income date format?
Based on that you can perform an ICONV on it and then an OCONV with the format as "DMDY[2,2,4]":@VM:"MCN". This will give you MMDDYYYY format.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Welcome aboard! Common date manipulations are covered extensively here. Spend a little time and browse the 100 thousand plus questions and answers.

If you want me to give you a hint, look for conversations regarding using ICONV and OCONV to facilitate date manipulations. Your solution could also be solved using simple string manipulation to remove the / character. Search for tips on using EREPLACE and CHANGE and TRIM. You can look these functions up in the DS BASIC manual available under your Start button for Ascential, under Online Documentation.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

DSG2B: It would probably help if you also explained what exactly that is doing, the 'how' of the 'what', if you will. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
arun_kumar
Participant
Posts: 58
Joined: Thu Feb 15, 2007 3:42 pm

regarding data conversion

Post by arun_kumar »

Hi,

can you make the question clear,you want the output to be in that specified foramt or data convesion.
Arunkumar..
tguthrie226
Participant
Posts: 3
Joined: Tue Mar 25, 2008 9:51 am
Location: Atlanta

Updated Information

Post by tguthrie226 »

I have tried:

Oconv(FedDepr.BEG_DEPR_DATE, "MDY[2,2,4]" :@VM:"MCN") which produces:
03/21/1999

I have also tried: Oconv(DateTimeStampToInternal(AsMast.A_DISP_DATE) , "DM[2]"):Oconv(DateTimeStampToInternal(AsMast.A_DISP_DATE) , "DD"):Oconv(DateTimeStampToInternal(AsMast.A_DISP_DATE) , "DY") Else "" which produces:
03011999

so it appears that it rolls the day portion of the date back the 1st each time.
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Re: Updated Information

Post by gateleys »

Try this -

Code: Select all

Oconv(FedDepr.BEG_DEPR_DATE, "MDY[2,2,4]","MCN")
The MCN conversion code extracts only the numerals from the input string.
gateleys
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

chulett wrote:DSG2B: It would probably help if you also explained what exactly that is doing, the 'how' of the 'what', if you will. :wink:
Sure. You can provide multiple mainpulations on a string using a single ICONV or OCONV function by delimiting the conversions with a value mark (@VM) character. Hence, first change the internal date to MM DD YYYY format and then apply "MCN" which will extract the numbers out of the date, in turn, getting rid of the spaces.

So gateleys conversion code is missing the @VM character. Hence, it will now be

Code: Select all

Oconv(FedDepr.BEG_DEPR_DATE, "MDY[2,2,4]":@VM:"MCN")
provided the incoming date is in internal format. Else change it to internal format by using ICONV().
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
tguthrie226
Participant
Posts: 3
Joined: Tue Mar 25, 2008 9:51 am
Location: Atlanta

Transform Function

Post by tguthrie226 »

I ended up building this transform and it works.

Ans = DSDate[6,2]:DSDate[9,2]:DSDate[1,4]

SunTrustDateFormatNew(FedDepr.BEG_DEPR_DATE)
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Why y'all given out the answers to our friend from Atlanta? Why not let them discover our rich answer history here? Sometimes you learn a lot more than finding out an answer you care about...
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

kcbland wrote:Why y'all given out the answers to our friend from Atlanta? Why not let them discover our rich answer history here? Sometimes you learn a lot more than finding out an answer you care about...
I was just explaining my cryptic code. Forgot to do it the first time. :roll:
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or:

Code: Select all

Convert("/","",Oconv(FedDepr.BEG_DEPR_DATE, "MDY[2,2,4]"))
Might make it a little more obvious what's going on.
-craig

"You can never have too many knives" -- Logan Nine Fingers
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

DSguru2B wrote:So gateleys conversion code is missing the @VM character.
Ooops!!

If you want to go without the Value Mark, you would need to go with a double call to Oconv -

Code: Select all

Oconv(Oconv(FedDepr.BEG_DEPR_DATE, "MDY[2,2,4]"),"MCN")
gateleys
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Given the original problem I'd use a DIGITS Transform.

Code: Select all

DIGITS(InLink.TheDate)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply