DS-PX Day from Date

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
SP_ETL
Participant
Posts: 2
Joined: Fri Nov 27, 2009 8:23 am
Location: Bangalore

DS-PX Day from Date

Post by SP_ETL »

Hi Folks

How to get lastday of the last week with referance to todays date(ie 20/0/2010).

Ex: suppose todays date is 05/01/2010 and I need last day of the last week(Ans should be 02/01/2010 ).
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

With the "%e" or "%E" format of DateToString() you can get the numeric day-of-week for a given date, and with "%ddd" you can get the numeric day-of-year for that date. Subtract the day-of-week from the day-of-year and then reconvert to a date using StringToDate() and you have solved your problem.
ray.wurlod
Participant
Posts: 54595
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What is your business rule for "last day of week"? In some countries weeks run from Sunday to Saturday, in other countries Monday to Sunday, etc. Without that knowledge no generic answer can be given.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Ray - that is why I posted both %e and %E as those cover the 2 different commonly used first weekday definitions.
SP_ETL
Participant
Posts: 2
Joined: Fri Nov 27, 2009 8:23 am
Location: Bangalore

Post by SP_ETL »

ray.wurlod wrote:What is your business rule for "last day of week"? In some countries weeks run from Sunday to Saturday, in other countries Monday to Sunday, etc. Without that knowledge no generic answer can be give ...
Its 1st Case Sunday to Saturday
Post Reply