Getting Number of Days from the 1st of the year.

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
m_muia
Participant
Posts: 6
Joined: Mon May 24, 2004 6:39 am

Getting Number of Days from the 1st of the year.

Post by m_muia »

I have been trying to get the number of days from the first of the year. I have tried using the Julian Date Function, but it does not appear to be what I was expecting. I have tried several other functions, but they have been unsuccessful. DaysSinceFromDate(%date%,%yyyy-mm-dd%) gives me compilation errors, I guess that the syntax or the source fields I am using may be incorrect. :?:
amsh76
Charter Member
Charter Member
Posts: 118
Joined: Wed Mar 10, 2004 10:58 pm

Post by amsh76 »

What is the format of your input Date ?
m_muia
Participant
Posts: 6
Joined: Mon May 24, 2004 6:39 am

Post by m_muia »

amsh76 wrote:What is the format of your input Date ?
The Date format is 'yyyy-mm-dd'
amsh76
Charter Member
Charter Member
Posts: 118
Joined: Wed Mar 10, 2004 10:58 pm

Post by amsh76 »

Of top of my head...what i can suggest is

Convert your input date in Internal Format through Iconv
and then convert that to Julian..through Oconv.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I would use

Code: Select all

JulianDayFromDate(today())-(JulianDayFromDate("01/01/2005")
(wishing that I could use Iconv & Oconv in PX!!!!! You could always use a BASIC transform stage and utilize the Iconv/Oconv capabilities of the Server edition, but you would lose some of the performance advantages of Px)
richdhan
Premium Member
Premium Member
Posts: 364
Joined: Thu Feb 12, 2004 12:24 am

Post by richdhan »

Hi,

I have used the DaysSinceFromDate function and it works perfectly. This is the syntax I used in the transformer

DaysSinceFromDate(CurrentDate(), DSLink2.FirstDay)

where DSLink2.FirstDay has been initialized to '2005-01-01'.

HTH
--Rich

Pleasure in job brings perfection in work
T42
Participant
Posts: 499
Joined: Thu Nov 11, 2004 6:45 pm

Post by T42 »

Didn't people around here learn anything from Y2k?

NEVER EVER HARD CODE VALUES IF YOU CAN HELP IT!

Here's your answer:

Code: Select all

YearDayFromDate(StringToDate(field, "%YYYY-%MM-%DD"))
This works for 7.1r2 (Just tested this.)
Post Reply