Data string '20090102' does not match format '%yyyy-%mm-%dd'

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
kollurianu
Premium Member
Premium Member
Posts: 614
Joined: Fri Feb 06, 2004 3:59 pm

Data string '20090102' does not match format '%yyyy-%mm-%dd'

Post by kollurianu »

I am getting following warning..


Data string '20090102' does not match format '%yyyy-%mm-%dd': an integer was expected to match tag %dd

I am getting input field as string as yyyymmdd .. trying to check if it is a valid date and converting to string to date..

Code: Select all

If ((Trim(DSLink2.ACCT_OPEN_DT) = '') Or (IsNull((DSLink2.ACCT_OPEN_DT)))  Or  (IsValidDate( Trim(DSLink2.ACCT_OPEN_DT))= 0 )) Then SetNull() Else  StringToDate(Trim(DSLink2.ACCT_OPEN_DT),"%yyyy%mm%dd")
Not sure what I am i missing here
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Your warning does not match up to the code you posted... meaning the error shows you using "-" delimiters between the date elements and yet your code as posted does not.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kollurianu
Premium Member
Premium Member
Posts: 614
Joined: Fri Feb 06, 2004 3:59 pm

Post by kollurianu »

But that is how the data is and the code is and cannot understand/get the warning..
kollurianu
Premium Member
Premium Member
Posts: 614
Joined: Fri Feb 06, 2004 3:59 pm

Post by kollurianu »

Data string '20060517' does not match format '%yyyy-%mm-%dd': an integer was expected to match tag %dd.

Still getting this warning after using
below expression

If IsValidDate(DSLink2.ACCT_OPEN_DT) Then StringToDate(DSLink2.ACCT_OPEN_DT,"%yyyy%mm%dd") Else SetNull()
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Check the syntax for IsValidDate... I'm assuming it is taking a default since you don't mention the date's format, try adding "%yyyy%mm%dd" to it as well.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

Check into the nuances of the IsValidDate function compared with the IsValid function with a "date" argument.

You should be using IsValid("date",...) to check the validity of a string. Especially when your string is in a non-default format such as yours.

Mike
kollurianu
Premium Member
Premium Member
Posts: 614
Joined: Fri Feb 06, 2004 3:59 pm

Post by kollurianu »

Thanks Craig and Mike..

But still not working...

I reformated the input string from YYYYMMDD to YYYY-mm-dd in a stage variable and then used the isvaliddate function still not working .. and giving the same error below.

APT_CombinedOperatorController,1: Data string '20000317' does not match format '%yyyy-%mm-%dd': an integer was expected to match tag %dd.

Here is the stage variable

TmpAcctOpDt

If IsNotNull(DSLink2.ACCT_OPEN_DT) And Len( Trim(DSLink2.ACCT_OPEN_DT)) = 8 Then DSLink2.ACCT_OPEN_DT[1,4]:'-':DSLink2.ACCT_OPEN_DT[5,2]:'-':DSLink2.ACCT_OPEN_DT[7,2] Else '0000-00-00'

then used below expression

If IsValidDate(TmpAcctOpDt) Then StringToDate(TmpAcctOpDt,"%yyyy-%mm-%dd") Else SetNull()

still not working.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

As Mike noted, you don't need all that but rather simply switch from IsValidDate (which needs a date not a string) to IsValid with a parameter of "date" and the format string.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

kollurianu wrote:APT_CombinedOperatorController,1: Data string '20000317' does not match format '%yyyy-%mm-%dd': an integer was expected to match tag %dd.
This error message is not a result of any of the code you've just posted. I suspect you're looking into the wrong derivation.

Start eliminating derivations until you've isolated it.

Mike
kollurianu
Premium Member
Premium Member
Posts: 614
Joined: Fri Feb 06, 2004 3:59 pm

Post by kollurianu »

chulett wrote:As Mike noted, you don't need all that but rather simply switch from IsValidDate (which needs a date not a string) to IsValid with a parameter of "date" and the format string. ...
Ok..

But does StringtoDate(TmpAcctOpDt,"%yyyy-%mm-%dd") function need the input date value in the yyyy-mm-dd format?
kollurianu
Premium Member
Premium Member
Posts: 614
Joined: Fri Feb 06, 2004 3:59 pm

Post by kollurianu »

Thanks Mike and Craig !!

this worked...

If IsValid("Date" , DSLink2.OPEN_DT, "%yyyy%mm%dd") Then StringToDate(DSLink2.OPEN_DT,"%yyyy%mm%dd") Else SetNull()
Post Reply