conversion of julian date of format 'yyyyjjj' to date

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
syam
Participant
Posts: 10
Joined: Wed Nov 29, 2006 5:03 am

conversion of julian date of format 'yyyyjjj' to date

Post by syam »

Hi All,

I want to convert the date format of the type 'yyyyjjj' ex:2006346 to date. and i am trying to do it by using the julianday to date function. but it's not working . The format of the output date is 'yyyy/mm/dd'. how to convert this .
Any help is appreciated.

syam.
SHYAM
boppanakrishna
Participant
Posts: 106
Joined: Thu Jul 27, 2006 10:05 pm
Location: Mumbai

Post by boppanakrishna »

hi syam ,
use stringto datefunction,,

syntax:
stringtodate(i/pstring[1,4]:"/":i/pstring[5,2]:"/":ipstring[7,2],"%yyyy/%mm/%dd")

try using the above function hope this helps you
syam
Participant
Posts: 10
Joined: Wed Nov 29, 2006 5:03 am

Post by syam »

WHAT I WANT IS CONVERSION OF JULIAN DATE TO DATE. HOW ICAN DO THIS BY USING STRING TO DATE. HOW TO CONVERT THE 2006346 TO DATE0F TYPE EG:2006/12/12 . WHAT IS THE FUNCTION USED FOR THIS CONVERSION. ANY WAYTHANKS FOR YOUR REPLY.
SHYAM
battaliou
Participant
Posts: 155
Joined: Mon Feb 24, 2003 7:28 am
Location: London
Contact:

Post by battaliou »

There's probably some other cool Julian date functions out there, but here's a quick solution:

dj = '2006346'
oconv(iconv(dj[1,4]:'/01/01','d/ymd[4,2,2]') + dj[5,3],'d/ymd[4,2,2]')

This simply adds internal days at 1st January 2006 plus julian days since (346) and outputs in the format d/ymd[4,2,2].

If you need this to run in enterprise edition, you will have to use a string to decimal conversion on the substring dj[5,3], probably best done by way of a stage variable.
3NF: Every non-key attribute must provide a fact about the key, the whole key, and nothing but the key. So help me Codd.
srinath
Participant
Posts: 9
Joined: Wed Nov 09, 2005 7:18 am

Post by srinath »

I think the julian date format will be CYYJJJ and the data will be like
dj = 106346

to convert the above one we can use this OCONV(ICONV(dj + 1900000,"D2/"),"D4/MDY").

You can use some other date formats for the above one to get the desired result.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

You have posted in a px forum and marked the job type as server, which one is it?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
syam
Participant
Posts: 10
Joined: Wed Nov 29, 2006 5:03 am

Post by syam »

the job type is parallel . and mentioned the same in the question also.
SHYAM
BalageBaju
Participant
Posts: 34
Joined: Fri Sep 22, 2006 10:59 pm
Location: India

Post by BalageBaju »

Sayam,

But you posted in Server Edition forum.
Plz mention your correct input format whether is it 2006346 or 106346 as per Srinaths post. I think the correct Julian day format is 106346.
Plz try with the function
"DateFromJulianDay"

Hope this will help you...
Regards,
Balaji.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Search. This has been covered before. Like here.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Apotluri
Premium Member
Premium Member
Posts: 25
Joined: Sun Dec 25, 2005 10:38 pm

Re: conversion of julian date of format 'yyyyjjj' to date

Post by Apotluri »

syam wrote:Hi All,

I want to convert the date format of the type 'yyyyjjj' ex:2006346 to date. and i am trying to do it by using the julianday to date function. but it's not working . The format of the output date is 'yyyy/mm/dd'. how to convert this .
Any help is appreciated.

syam.
Hi Syam,

Actually, the data you are getting is not Julian date, it is Ordinal date.
If it is a parallel job, use 'basic transformer' and try with
Oconv(Iconv(link.fieldname,"DYJ"), "D-YMD[4,2,2]"):' 00:00:00'

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

Post by ray.wurlod »

In a server job,

Code: Select all

Oconv(Iconv(InLink.TheDate, "DYJ"), "D/YMD[4,2,2]")
In a parallel job you could use this expression in a BASIC Transformer stage, if you didn't mind the performance penalty.

Otherwise you will need to use parallel job functions. Why not start a new thread on the parallel forum?
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