Decimal to 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
skumar
Participant
Posts: 88
Joined: Thu May 25, 2006 5:11 am
Location: Hyderabad

Decimal to Date Conversion

Post by skumar »

Hi All,

I am getting the date as decimal in my source like 2007001.In this 2007 is the year and 001 is the day of the year...and i want to get the date from that.I want my output as 2007-01-01.can somebody help me out how to get this.

Thanks in advance....


Regards,
skumar.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You have the year and the ordinal number of the day in the year. You can extract these components with arithmetic operations/functions. Divide by 1000 to get the year, take the remainder (Mod() function) to get the day.

Then you can use date conversion functions to generate a Date from those components.

Format does not come into it unless you require a string to be generated. In that case, use another conversion function to convert the date into a string.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
altis
Premium Member
Premium Member
Posts: 11
Joined: Thu Mar 29, 2007 1:38 am

Re: Decimal to Date Conversion

Post by altis »

Hi,

I feel you need to change the logic that Ray said, a little bit. Get the year and ordinal number of the day in the year according to Ray. Then u need to subtract one day from the ordinal number of the day calculated above and then use DateFromDaysSince function. Like, if value comes from src is 2007002, u will get year as 2007 and day as 2. use 2007-01-01 and 1 (i.e 2-1) as the argument of that function then u will get the correct result (i.e 2007-01-02).

skumar wrote:Hi All,

I am getting the date as decimal in my source like 2007001.In this 2007 is the year and 001 is the day of the year...and i want to get the date from that.I want my output as 2007-01-01.can somebody help me out how to get this.

Thanks in advance....


Regards,
skumar.
Altis Consulting Pty Ltd
www.altis.com.au
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Do you purport to represent Altis? If not, please choose a different nick.
If so, please endeavour to use a professional standard of written English: the second person personal pronoun is spelled "you". DSXchange is not a mobile phone. Sentences ought really not to begin with "Like, ".
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