Implementing date logic

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
raji33
Premium Member
Premium Member
Posts: 151
Joined: Thu Sep 23, 2010 9:21 pm
Location: NJ

Implementing date logic

Post by raji33 »

Hi

Can any one help me with this scenario.

I have current date, If current date falls in between

yyyy-mm-02,
!
!
!yyyy-mm-05 of month then get the last date of previous month.

for ex:current date =2013-07-02 then i need to populate as 2013-06-30
simillarly if date falls as 2013-07-03 then also its 2013-06-30

Thanks
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Re: Implementing date logic

Post by SURA »

This can be done using different ways.

I would prefer to get the value from DB itself.

If your source is DB, then you can bring an additional column called First Date Of the month with value. Then that date can be compared in Datastage.
Thanks
Ram
----------------------------------
Revealing your ignorance is fine, because you get a chance to learn.
moalik
Participant
Posts: 39
Joined: Thu Sep 15, 2011 8:15 am
Location: Melbourne

Post by moalik »

Hi Raji,

In DataStage we have a Transform called MONTH.FIRST.

This Transform Returns a numeric internal date corresponding to the first day of a month given in MONTH.TAG format (YYYY-MM).
Example: MONTH.FIRST("1993-02") => 9164".

For your logic Fetch "YYYY-MM" from your input column and use this transform. Once you get the Numeric internal date from that subtract 1 from the value.

Example: MONTH.FIRST("1993-02") => 9164" , this is the 1st Day of the month,to get the last month last date just do "9164-1" which gives 9163.

The convert the result using oconv(result,"D-YMD[4,2,2]").

Now just compare the dates in and pass the above value once the condition is satisfied.

Hopes this answers your solution. :)
Mohsin Khan
Datastage Consultant
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Post by SURA »

YES for SERVER JOBS. But the request is for PARALLEL JOB.
Thanks
Ram
----------------------------------
Revealing your ignorance is fine, because you get a chance to learn.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Transforms are available in BASIC Transformer stage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

In parallel Transformer stage, use MonthDayFromDate() to determine the day number for your range check. Use DateFromDaysSince() and that value to calculate the date of the first day of the current month or the last day of the previous month.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

Check this post for a starter. apart for this you need to add logic to find if the data is between the range you want.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You might also consult the FAQ post on Common Date Offsets in Parallel Jobs
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