Regular Date To JulianDate

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
lak4u
Participant
Posts: 43
Joined: Mon Nov 03, 2008 10:00 pm

Regular Date To JulianDate

Post by lak4u »

I need to convert DataStage current Date (2009-05-13) to JulianDate

Example:

from source I am getting Date: 109096

i.e. 1900+109 =2009
096 = 0406 (April 06)

I am trying below but I couldn't get it...
Oconv(Iconv("2009-04-06","D4-YMD[4,2,2]"),"DJ")

FOR JulianDateToTimeStamp I am able to convert ...
OCONV(ICONV(%JulianDate% + 1900000, "D4-"), "D4-YMD[4,2,2]")


Please anybody can help?

Thanks in advance
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Can you break up the problem into 2 steps, first the ICONV and then the OCONV?
When you get "109096" what function do you use and do you convert it to a display date or a DataStage internal date?
lak4u
Participant
Posts: 43
Joined: Mon Nov 03, 2008 10:00 pm

Post by lak4u »

ArndW wrote:Can you break up the problem into 2 steps, first the ICONV and then the OCONV?
When you get "109096" what function do you use and do you convert it to a display date or a DataStage internal date? ...
Thanks for reply.

I am able to converting
OCONV(ICONV("109096" + 1900000, "D4-"), "D4-YMD[4,2,2]")

I am passing my Column name which is "109096" and it displays Date = 2009-04-06

Now I need just reverse if I pass 2009-04-06 then I need "109096"
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Have you tried the inverse function,

Code: Select all

OCONV(ICONV("2009-04-06","D4-YMD[4,2,2]")[b]-1900000[/b],"DJ")[code]
lak4u
Participant
Posts: 43
Joined: Mon Nov 03, 2008 10:00 pm

Post by lak4u »

ArndW wrote:Have you tried the inverse function,

Code: Select all

OCONV(ICONV("2009-04-06","D4-YMD[4,2,2]")[b]-1900000[/b],"DJ")[code] ...[/quote]

Can you please elaborate ? what is [code] ?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Broken formatting tag, ignore it. Should have looked like this:

Code: Select all

OCONV(ICONV("2009-04-06","D4-YMD[4,2,2]") -1900000 ,"DJ")
-craig

"You can never have too many knives" -- Logan Nine Fingers
lak4u
Participant
Posts: 43
Joined: Mon Nov 03, 2008 10:00 pm

Post by lak4u »

ArndW wrote:Have you tried the inverse function,

Code: Select all

OCONV(ICONV("2009-04-06","D4-YMD[4,2,2]")[b]-1900000[/b],"DJ")[code] ...[/quote]

I tried this and got value "114", I never used inverse function,can you please tellme the how to use this [code]?

Thaks
lak4u
Participant
Posts: 43
Joined: Mon Nov 03, 2008 10:00 pm

Post by lak4u »

chulett wrote:Broken formatting tag, ignore it. Should have looked like this:

Code: Select all

OCONV(ICONV("2009-04-06","D4-YMD[4,2,2]") -1900000 ,"DJ")
...

I tried this.I got value "114"
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I don't have access to DS or the manuals, but I kind of doubt your 1900000 addition/subtraction - that number looks wrong. Where did you get that and are you certain it works?
lak4u
Participant
Posts: 43
Joined: Mon Nov 03, 2008 10:00 pm

Post by lak4u »

ArndW wrote:I don't have access to DS or the manuals, but I kind of doubt your 1900000 addition/subtraction - that number looks wrong. Where did you get that and are you certain it works? ...
Thanks.
I am not sure about this 1900000 but is showing currect result

FOR JulianDateToDate I am able see currect result...
OCONV(ICONV("109096" + 1900000, "D4-"), "D4-YMD[4,2,2]")

result : 2009-04-06
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Re: Reguler Date To JulianDate

Post by Kryt0n »

lak4u wrote:I need to convert DataStage current Date (2009-05-13) to JulianDate

Example:

from source I am getting Date: 109096

i.e. 1900+109 =2009
096 = 0406 (April 06)
Are you trying to convert a value from source or current date?

Assuming your source is always six characters, form your date (doing as you are doing), convert to internal format and add 2439856 (this being 31 December 1967 in Julian Date).

The OCONV format "DJ" gives Julian Year Date and not Julian Date that is why you get 114.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: Reguler Date To JulianDate

Post by chulett »

Kryt0n wrote:The OCONV format "DJ" gives Julian Year Date and not Julian Date that is why you get 114.
Also known as an "Ordinal" date - the day number of that year.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply