Date Conversion

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
bucks
Premium Member
Premium Member
Posts: 21
Joined: Tue Feb 20, 2007 1:31 pm

Date Conversion

Post by bucks »

Hi,
I need convert a date format which is year and a day ex:-2007045 to a format 2007-02-14.

can anyone help me regading this?

Thanks !
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Hi and Welcome to Dsxchange :D !!!!!

Try using

Code: Select all

StingToDate(Input.field, "%YYYY%DDD")
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Mohanram
Participant
Posts: 9
Joined: Tue Jan 30, 2007 5:21 am

Re: Date Conversion

Post by Mohanram »

HI ,
Try it using iconv and Oconv function..
ex:if the date is 2007032 which represents 2007-02-01
use the below mentioned function in the transformation stage


OCONV(ICONV('2007032','DYD[4,3]'),'D-YMD[4,2,2]')
Thanks and Regards,
Mohan Ram.T
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

The input looks like Julian date to me. Try

Code: Select all

DateFromJulianDay(in.Date)
ICONV/OCONV is not present in parallel jobs unless you use a basic transformer.
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 »

Technically, that's actually an 'Ordinal' date - the year followed by the number of the day within that year. However, from what I recall, that DateFromJulianDay function is actually expecting an Ordinal date. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Your right Craig. Somehow 'they' got the naming wrong for the function.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
bucks
Premium Member
Premium Member
Posts: 21
Joined: Tue Feb 20, 2007 1:31 pm

Post by bucks »

Thanks kumar and for all the replies,

I have used lengthy procedure for this conversion using function DateFromDaysSince(), using stage var.


Funny thing is, it worked with simple StringToDate(datefield,"%yyyy%ddd").


:lol:
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Re: Date Conversion

Post by kumar_s »

Hi Mohan,

Iconv/Oconv are BASIC function used in Server jobs, and Basic Transformer in PX jobs which are seldom used.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

bucks wrote:Thanks kumar and for all the replies,

I have used lengthy procedure for this conversion using function DateFromDaysSince(), using stage var.


Funny thing is, it worked with simple StringToDate(datefield,"%yyyy%ddd").


:lol:
Do you mind marking the post as resolved.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Post Reply