DSXchange: DataStage and IBM Websphere Data Integration Forum
View next topic
View previous topic
Add To Favorites
This topic has been marked "Resolved."
Author Message
dbdecoy



Group memberships:
Premium Members

Joined: 15 Jul 2008
Posts: 17
Location: Hyderabad
Points: 174

Post Posted: Fri Feb 19, 2016 1:10 am Reply with quote    Back to top    

DataStage® Release: 8x
Job Type: Server
OS: Unix
Can anyone help me in converting normal date into Julian Date.

For eg: if we input 20160219 my output will be 116050(CYYDDD) format.

I have code for the reverse conversion (From Julian to Normal Date)

Code:
OCONV(ICONV(Arg1 + 1900000, "D4-"), "D4-YMD[4,2,2]")


But not able to find a solution for converting other way round
chulett

Premium Poster


since January 2006

Group memberships:
Premium Members, Inner Circle, Server to Parallel Transition Group

Joined: 12 Nov 2002
Posts: 42273
Location: Denver, CO
Points: 217068

Post Posted: Fri Feb 19, 2016 8:08 am Reply with quote    Back to top    

Warning (pet peeve alert) but that is not a Julian date, which may explain your difficulty in finding the proper solution. From the docs: Quote: A Julian day specifies the date as the n ...

_________________
-craig

Watch out where the huskies go and don't you eat that yellow snow
Rate this response:  
Not yet rated
Thomas.B
Participant



Joined: 09 Apr 2015
Posts: 57
Location: France - Nantes
Points: 369

Post Posted: Fri Feb 19, 2016 8:09 am Reply with quote    Back to top    

There is a forum dedicated to DataStage Server >Here< .
Perhaps you will have more answers there.

Edit : Damn, craig is fast !

_________________
BI Consultant
Business & Decision

Last edited by Thomas.B on Fri Feb 19, 2016 8:11 am; edited 1 time in total
Rate this response:  
Not yet rated
chulett

Premium Poster


since January 2006

Group memberships:
Premium Members, Inner Circle, Server to Parallel Transition Group

Joined: 12 Nov 2002
Posts: 42273
Location: Denver, CO
Points: 217068

Post Posted: Fri Feb 19, 2016 8:10 am Reply with quote    Back to top    

And crap, just like that not the answer you are looking for. Didn't notice you posted Server code in the PX forum, let's get you over into the right one and see how we can approach this with our old friends the 'Conv Brothers'. Wink

_________________
-craig

Watch out where the huskies go and don't you eat that yellow snow
Rate this response:  
Not yet rated
chulett

Premium Poster


since January 2006

Group memberships:
Premium Members, Inner Circle, Server to Parallel Transition Group

Joined: 12 Nov 2002
Posts: 42273
Location: Denver, CO
Points: 217068

Post Posted: Fri Feb 19, 2016 8:12 am Reply with quote    Back to top    

Thanks Thomas, moved it. Unfortunately, right off the top of my head I don't have an answer and don't have the proper time to research. I wonder if Ray's freely available date routines do that kind of conversion?

_________________
-craig

Watch out where the huskies go and don't you eat that yellow snow
Rate this response:  
Not yet rated
qt_ky



Group memberships:
Premium Members

Joined: 03 Aug 2011
Posts: 2665
Location: USA
Points: 19822

Post Posted: Fri Feb 19, 2016 8:55 am Reply with quote    Back to top    

I once worked in an AS/400 shop that also incorrectly referred to these as Julian dates every day. Coincidentally, the date conversion code to get the day number of the year is J...

You could try something like this code below (where in this example, Date() represents today's internal date; modify as needed). Of course you would need to do the if then else logic to determine the first digit for the century.

Code:
'1' : Oconv(Date(), 'DY[2]') : Oconv(Date(), 'DJ[3]')

_________________
Choose a job you love, and you will never have to work a day in your life. - Confucius
Rate this response:  
Not yet rated
chulett

Premium Poster


since January 2006

Group memberships:
Premium Members, Inner Circle, Server to Parallel Transition Group

Joined: 12 Nov 2002
Posts: 42273
Location: Denver, CO
Points: 217068

Post Posted: Fri Feb 19, 2016 9:35 am Reply with quote    Back to top    

Ah yes, I recall that now but funny it didn't come up in my quickie search of the Server pdf. Further perpetuating the myth of the Julian date! And one of the Mainframe folks here gave me a "Perpetual Julian Date" calendar just because they knew it would irk me. Wink

And both of you guys need a "2" on the front, not a "1".

_________________
-craig

Watch out where the huskies go and don't you eat that yellow snow
Rate this response:  
Not yet rated
qt_ky



Group memberships:
Premium Members

Joined: 03 Aug 2011
Posts: 2665
Location: USA
Points: 19822

Post Posted: Fri Feb 19, 2016 1:34 pm Reply with quote    Back to top    

That's funny.

Where I found the code was in the BASIC Reference Guide pdf (section: Correlative and Conversion Codes / Date Conversion): J Requests only the day number within the year (1 through 366). Notice that "Julian" is not part of the description...

From what I recall, the folks I worked with used century 0 to denote the 1900's and 1 to denote the 2000's. Using that logic, a 2 would denote the 2100's, so maybe it varies.

_________________
Choose a job you love, and you will never have to work a day in your life. - Confucius
Rate this response:  
Not yet rated
chulett

Premium Poster


since January 2006

Group memberships:
Premium Members, Inner Circle, Server to Parallel Transition Group

Joined: 12 Nov 2002
Posts: 42273
Location: Denver, CO
Points: 217068

Post Posted: Fri Feb 19, 2016 2:38 pm Reply with quote    Back to top    

Ah... that could be. Use whatever Century value is appropriate in your shop based on the incoming date.

_________________
-craig

Watch out where the huskies go and don't you eat that yellow snow
Rate this response:  
Not yet rated
qt_ky



Group memberships:
Premium Members

Joined: 03 Aug 2011
Posts: 2665
Location: USA
Points: 19822

Post Posted: Fri Feb 19, 2016 2:56 pm Reply with quote    Back to top    

Just don't plan on supporting dates from the 1800's or earlier! Laughing

_________________
Choose a job you love, and you will never have to work a day in your life. - Confucius
Rate this response:  
Not yet rated
ray.wurlod

Premium Poster
Participant

Group memberships:
Premium Members, Inner Circle, Australia Usergroup, Server to Parallel Transition Group

Joined: 23 Oct 2002
Posts: 54070
Location: Sydney, Australia
Points: 293276

Post Posted: Sun Feb 21, 2016 3:59 pm Reply with quote    Back to top    

Try Code: Oconv(Iconv(InLink.TheDate, "DYMD"), "DYJ['1',2,3]" : @VM : "MCN") You may like to finagle the century indicator based ...

_________________
RXP Services Ltd
Melbourne | Canberra | Sydney | Hong Kong | Hobart | Brisbane
currently hiring: Canberra, Sydney and Melbourne
Rate this response:  
Not yet rated
dbdecoy



Group memberships:
Premium Members

Joined: 15 Jul 2008
Posts: 17
Location: Hyderabad
Points: 174

Post Posted: Sun Feb 21, 2016 10:58 pm Reply with quote    Back to top    

Thanks for all the replies.Below code is working as per my requirement

Code:
'1' : Oconv(Date(), 'DY[2]') : Oconv(Date(), 'DJ[3]')
Rate this response:  
Not yet rated
ray.wurlod

Premium Poster
Participant

Group memberships:
Premium Members, Inner Circle, Australia Usergroup, Server to Parallel Transition Group

Joined: 23 Oct 2002
Posts: 54070
Location: Sydney, Australia
Points: 293276

Post Posted: Sun Feb 21, 2016 11:02 pm Reply with quote    Back to top    

It is, but it's neither maximally efficient nor maximally flexible.

_________________
RXP Services Ltd
Melbourne | Canberra | Sydney | Hong Kong | Hobart | Brisbane
currently hiring: Canberra, Sydney and Melbourne
Rate this response:  
Not yet rated
Display posts from previous:       

Add To Favorites
View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2002 phpBB Group
Theme & Graphics by Daz :: Portal by Smartor
All times are GMT - 6 Hours