OConv issue

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
dr.murthy
Participant
Posts: 224
Joined: Sun Dec 07, 2008 8:47 am
Location: delhi

OConv issue

Post by dr.murthy »

Hi

am going to convert the data from D/MDY(Time stamp) format to D-YMD date format using below syntax
OConv(IConv(Arg1[1,10],"D/MDY[2,2,4"),"D-YMD[4,2,2]")
But its failed for below dates.
06/1/2010 0:00:00 because its having data part as 8 characters.

any suggestions???
D.N .MURTHY
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Use Field() rather than substring to get the date portion. You could also try using just "D" in the IConv call rather than your specific mask with those sizes, it is pretty darn smart about figuring dates out in its own.
-craig

"You can never have too many knives" -- Logan Nine Fingers
dr.murthy
Participant
Posts: 224
Joined: Sun Dec 07, 2008 8:47 am
Location: delhi

Post by dr.murthy »

Thanks for respond, am not supposed to use field function for this scenario because
Source
6/1/2010 0:00:00 am getting o/p 2010-6-1 but i need 2010-06-01, so i used Conversion function to handle this .
its failed for this format (6/1/2010 0:00:00) dates, when i fetch first ten characters its getting 6/1/2010 0
D.N .MURTHY
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:?

Use Field() to fetch the first field from a 'space' delimited string, then it won't matter how big it is... or isn't. You cannot simply fetch 10 characters when your date size is not fixed.
-craig

"You can never have too many knives" -- Logan Nine Fingers
vinnz
Participant
Posts: 92
Joined: Tue Feb 17, 2004 9:23 pm

Post by vinnz »

As craig suggested, use something like the below assuming your data is the first field in the space delimited string and there are no leading spaces

Code: Select all

Oconv(Iconv(Field(myDate,' ',1), "D/MDY"), "D-YMD[4,2,2]")
Post Reply