Date-1

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
khaja.arshad
Participant
Posts: 30
Joined: Mon May 29, 2006 11:19 pm

Date-1

Post by khaja.arshad »

Hello all

Im trying to get the previous date from the below derivation

StringToDate(trim(DSLink6.end_serv_date),"%dd-%mmm-%yy")-1

here link DSLink6.end_serv_date is a varchar type

while im trying above im getting the compilation error as


Error in output column derivation expression for column End_Serv_Date in link DSLink7. Invalid conversion requested from a date to a dfloat.

can any one help me out

Thanks in Advance
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

You have successfully converted your string to a date, but that datatype doesn't allow numerical math to be performed on it, so DS tries to convert the date to a dfloat and fails (because no implicit conversion rules are defined). You need to use one of the date conversion functions such as DateFromDaysSince() .
khaja.arshad
Participant
Posts: 30
Joined: Mon May 29, 2006 11:19 pm

Post by khaja.arshad »

Hello AndrW

im unable to see your reply completely

can you please share me your knowledge for this time

Thanks
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The short form is to use the DateFromDaysSince() function.
khaja.arshad
Participant
Posts: 30
Joined: Mon May 29, 2006 11:19 pm

Post by khaja.arshad »

Hello Andrw

Iam getting the date value in Varchar format

i have converted it in to Date format YYYY-MM-DD Using string_to_date function i have put it in to staging varaible the Field name is DT

in Transformer im Using
DateFromDaysSince(%number%,[%"yyyy-mm-dd"%])

im Substituting the the values like DateFromDaysSince(2, DT)

In Run time it is giving error as follows

APT_CombinedOperatorController,0: Caught exception from runLocally(): APT_ParseError: Parsing parameters "**********" for conversion "date=date_from_days_since[**********](int32)": APT_Conversion_Date_DaysSince: Invalid Date [**********] used for date_from_days_since type conversion.
Operator signalled one or more errors.


Can you tell me where im going wrong

Thanks in Advance
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Try putting your stage variable into an output link to a peek stage. You will see that you most likely did not convert your date correctly.
niranjansigeni
Participant
Posts: 7
Joined: Sat Sep 09, 2006 7:01 pm
Location: Jersey

Re: Date-1

Post by niranjansigeni »

Hi

It may be a late reply, but i am posting you the answer. May be helpful for someone later on..

try this

DateFromJulianDay(JulianDayFromDate(your_date)-1)

Thanks










khaja.arshad wrote:Hello all

Im trying to get the previous date from the below derivation

StringToDate(trim(DSLink6.end_serv_date),"%dd-%mmm-%yy")-1

here link DSLink6.end_serv_date is a varchar type

while im trying above im getting the compilation error as


Error in output column derivation expression for column End_Serv_Date in link DSLink7. Invalid conversion requested from a date to a dfloat.

can any one help me out

Thanks in Advance
niranjansigeni
Participant
Posts: 7
Joined: Sat Sep 09, 2006 7:01 pm
Location: Jersey

Re: Date-1

Post by niranjansigeni »

Hi

It may be a late reply, but i am posting you the answer. May be helpful for someone later on..

try this

DateFromJulianDay(JulianDayFromDate(your_date)-1)

Thanks










khaja.arshad wrote:Hello all

Im trying to get the previous date from the below derivation

StringToDate(trim(DSLink6.end_serv_date),"%dd-%mmm-%yy")-1

here link DSLink6.end_serv_date is a varchar type

while im trying above im getting the compilation error as


Error in output column derivation expression for column End_Serv_Date in link DSLink7. Invalid conversion requested from a date to a dfloat.

can any one help me out

Thanks in Advance
naveen19
Participant
Posts: 52
Joined: Tue Mar 06, 2007 9:08 am
Location: India
Contact:

Post by naveen19 »

Hi,

any way i am just hadding little bit flavour to niranjansigeni post

create stage variables
1.In that stage variables properties change the datatype as date
2.And the output column should be the date


StringToDate(IP.ED_DATE,"%yyyy-%mm-%dd")-- sv

piont sv to output column

in that Derivation apply

DateFromJulianDay(JulianDayFromDate(sv)-1)

as guided by niranjansigeni

U will get the output perfect..


Regards
Naveen.K
Post Reply