Display the long name of the 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

rajeevm
Participant
Posts: 135
Joined: Sun Jan 22, 2006 10:44 am

Display the long name of the day

Post by rajeevm »

Hi All,

I am facing a problem with the Date format . My source has a issue_dt column . I have to check the date whether its sunday or not. If its sunday I have to change the Edition_Cd to 14 else pass the same edition code from source.

How do I check whether the given date is sunday
I really appreciate your help

Thanks
rajeev
vinothkumar
Participant
Posts: 342
Joined: Tue Nov 04, 2008 10:38 am
Location: Chennai, India

Post by vinothkumar »

Check WeekdayFromDate function.
rajeevm
Participant
Posts: 135
Joined: Sun Jan 22, 2006 10:44 am

Post by rajeevm »

I checked that but the values are not passing thru the target

I used the following :

If WeekdayFromDate(To_New_isrt_trans.ISSUE_DT,'SUNDAY')
And To_New_isrt_trans.EDITION_CODE='01'
And IsNotNull(To_New_isrt_trans.ROUTE_CD)
then To_New_isrt_trans.EDITION_CODE='14'
else To_New_isrt_trans.EDITION_CODE

Please help me.

Thanks
rajeev
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Your syntax for the WeekdayFromDate function is incorrect. Recheck the documentation and adjust accordingly.
-craig

"You can never have too many knives" -- Logan Nine Fingers
rajeevm
Participant
Posts: 135
Joined: Sun Jan 22, 2006 10:44 am

Post by rajeevm »

The syntax shown in the document as Date(Origin day) I could not able to understand . Please let me know the correct syntax.

Thanks
rajeev
vinothkumar
Participant
Posts: 342
Joined: Tue Nov 04, 2008 10:38 am
Location: Chennai, India

Post by vinothkumar »

stageVar=WeekdayFromDate(To_New_isrt_trans.ISSUE_DT)
If the value of stageVar is 0 then it is Sunday I beleive. That you can test with a sample value. As a whole, this function will return the Day number (i.e 0 -Sunday , 1 - Monday,.....)
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Pass in the date and it will pass out the weekday number, 0 thru 6, where 0 = Sunday since sunday is the default 'origin day'. There is also a way to override the origin day if you want the week to start on a different day like Monday but I wouldn't worry about that in your case.
-craig

"You can never have too many knives" -- Logan Nine Fingers
rajeevm
Participant
Posts: 135
Joined: Sun Jan 22, 2006 10:44 am

Post by rajeevm »

I know that it gives the day number how to check that the given date is sunday . So I need to change the syntax as below

If WeekdayFromDate(To_New_isrt_trans.ISSUE_DT) =0 And To_New_isrt_trans.EDITION_CODE='01'
And IsNotNull(To_New_isrt_trans.ROUTE_CD)
then To_New_isrt_trans.EDITION_CODE='14'
else To_New_isrt_trans.EDITION_CODE


So is this way I should proceed

Please let me know.

Thanks
rajeev
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Yes.
-craig

"You can never have too many knives" -- Logan Nine Fingers
rajeevm
Participant
Posts: 135
Joined: Sun Jan 22, 2006 10:44 am

Post by rajeevm »

Hi chulett,

If I proceed the way I mentioned earlier . The data is not getting correctly into the target.

If its sunday then Edition_Cd=14 and Route_cd ='B:Route_Id'

Now , the data is loading in this way Way Edition_Cd=0 and Route_CD=B:Rout

Was there anything wrong in the syntax.

I really appreciate your help

Thanks
rajeev
vinothkumar
Participant
Posts: 342
Joined: Tue Nov 04, 2008 10:38 am
Location: Chennai, India

Post by vinothkumar »

How about the other 2 clauses that you gave in IF condtion. Are they true for your current scenario
rajeevm
Participant
Posts: 135
Joined: Sun Jan 22, 2006 10:44 am

Post by rajeevm »

yes they are true
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

There's no "and" after the "then". Do the Sunday check in a stage variable and then check it in both field's derivations.
-craig

"You can never have too many knives" -- Logan Nine Fingers
rajeevm
Participant
Posts: 135
Joined: Sun Jan 22, 2006 10:44 am

Post by rajeevm »

No the sunday is checked in the derivations against two columns

For Edition_Cd Column

If WeekdayFromDate(To_New_isrt_trans.ISSUE_DT) is Sunday
And To_New_isrt_trans.EDITION_CODE='01'
And IsNotNull(To_New_isrt_trans.ROUTE_CD)
then To_New_isrt_trans.EDITION_CODE='14'
else To_New_isrt_trans.EDITION_CODE

For Route_cd Column:

If WeekdayFromDate(To_New_isrt_trans.ISSUE_DT) is Sunday
And To_New_isrt_trans.EDITION_CODE='01'
And IsNotNull(To_New_isrt_trans.ROUTE_CD)
Then 'B:To_New_isrt_trans.ROUTE_ID'
Else To_New_isrt_trans.ROUTE_ID

I tried your syntax chulett but still not working .

Kindly please help me out with this.

Thanks
rajeev
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Where did "is Sunday" come from? You need to check for "= 0" as you posted earlier.
-craig

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