If Date is Sunday,Change it to Saturday(Previous DAy)

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
anudeepdasari001
Participant
Posts: 58
Joined: Mon Dec 14, 2015 3:16 pm
Location: Arizona

If Date is Sunday,Change it to Saturday(Previous DAy)

Post by anudeepdasari001 »

In my job i need to make a change which says,, If the Ship_date is Sunday, Change it to previous day i.e Saturday or else keepp the Ship Date for other days,
FYI the Ship date is Timestamp feild

Please if Someone can help me
anudpETL
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Okay, which part do you need help with? Rather than spoon-feed an answer, would rather do more of a nudge in the proper direction. Or at least give that a shot. :wink:

The Parallel Transform functions are all documented and the section on 'Date and Time Functions' will be very helpful here. You can use them to determine the "Day of Week" and then if it is a Sunday, decrement the date by one day. Use them in stage variables in a transformer to make the date change that you need. Give that a shot and let us know if you have any specific questions!
-craig

"You can never have too many knives" -- Logan Nine Fingers
Teej
Participant
Posts: 677
Joined: Fri Aug 08, 2003 9:26 am
Location: USA

Post by Teej »

Look at this page:

http://www.ibm.com/support/knowledgecen ... ml?lang=en

Particularly: WeekdayFromDate()

-T.J.
anudeepdasari001
Participant
Posts: 58
Joined: Mon Dec 14, 2015 3:16 pm
Location: Arizona

Post by anudeepdasari001 »

I Tried Doing this for that,

if WeekdayFromDate(lnk_out_xfm_gbl_ord.ORD_SHIP_DT)='SUNDAY' then PreviousWeekdayFromDate(lnk_out_xfm_gbl_ord.ORD_SHIP_DT,"SATURDAY") else lnk_out_xfm_gbl_ord.ORD_SHIP_DT


As this is the Timestamp feild
anudpETL
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

And?
-craig

"You can never have too many knives" -- Logan Nine Fingers
Teej
Participant
Posts: 677
Joined: Fri Aug 08, 2003 9:26 am
Location: USA

Post by Teej »

Please review the documentation again carefully. For WeekdayFromDate, it expects a Date field, and will return a numeric value.

A numeric value is never equal to a string called "Sunday".

There is also type conversion functions detailed here:

http://www.ibm.com/support/knowledgecen ... tions.html

That would help address your conversion issues (from timestamp to date).

I know we are not giving you the answer -- we want you to find the answer yourself using those reference materials. This way, you will become a much better developer for your customer.
-T.J.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Teej wrote:For WeekdayFromDate, it expects a Date field, and will return a numeric value.
Specifically when it says the "day number of the week" is returned it means a 1 for Sunday (2 for Monday, etc) because Sunday is the first day of the week by default. You can override that if desired but I generally don't see a need to.
-craig

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