How to find Last sunday of a month

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
HemaV
Participant
Posts: 63
Joined: Wed Jan 09, 2008 1:38 am
Location: Bangalore

How to find Last sunday of a month

Post by HemaV »

Hi All,

My requirement says:

my output column should be 1 from Last sunday of March till last sunday of October and other times it will be 0.

How to do this logic in transformer?

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

Post by ray.wurlod »

Calculate the date of the last day of March as

Code: Select all

DateFromComponents(#jpYear#,3,31)
Use a similar technique for the last day of October.

Calculate the last Sunday of March as

Code: Select all

PreviousWeekdayFromDate(svLastDayOfMarch,'Sunday')
Use a similar technique for the last Sunday of October.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
HemaV
Participant
Posts: 63
Joined: Wed Jan 09, 2008 1:38 am
Location: Bangalore

Post by HemaV »

I'm using Datastage 8.1 version and i didnt find the function DateFromComponents().

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

Post by ray.wurlod »

Then just use PreviousWeekdayFromDate() with a hard coded (or parameterised) date.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Kartheek kesarla
Participant
Posts: 1
Joined: Fri May 03, 2013 12:16 am

Re: How to find Last sunday of a month

Post by Kartheek kesarla »

Hi ,

Hope below logic solve your problem

Code: Select all

If column <= NthWeekdayFromDate(2013-04-01, "SUNDAY",-1) and  column >= NthWeekdayFromDate(2013-11-01, "SUNDAY",-1)Then 1 Else  0


Regards
Kartheek Kumar Kesarla
Regards
Kartheek Kumar Kesarla
IT Database Analyst
Post Reply