getting error on 00000000 while doing stringtodate

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
times29
Premium Member
Premium Member
Posts: 202
Joined: Mon Sep 22, 2008 3:47 pm

getting error on 00000000 while doing stringtodate

Post by times29 »

HI,
i am getting below error while doing
StringToDate(DSLink77.AAA,"%yyyy-%mm-%dd ")

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

Issue is some data is good(20110302) and some is not (00000000) and we need to convert this from varchar to date

But again 00000000 we can make it null as this is not useful for business
GJ_Stage
Participant
Posts: 131
Joined: Mon Oct 27, 2008 6:59 am

Post by GJ_Stage »

Hi,

Apply condition if string is 00000000 then set as null else you can use tringToDate(DSLink77.AAA,"%yyyy-%mm-%dd ")
Jothi
times29
Premium Member
Premium Member
Posts: 202
Joined: Mon Sep 22, 2008 3:47 pm

Post by times29 »

getting warning now

If DSLink77.ANLA_AIBDT = '00000000' Then setnull() Else StringToDate(DSLink77.ANLA_AIBDT,"%yyyy-%mm-%dd")

TFM_ANLA,1: Data string '20091231' does not match format '%yyyy-%mm-%dd': an integer was expected to match tag %dd.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Your format string needs to match the data coming in. Do you have dashes in your data string?
-craig

"You can never have too many knives" -- Logan Nine Fingers
times29
Premium Member
Premium Member
Posts: 202
Joined: Mon Sep 22, 2008 3:47 pm

Post by times29 »

Data comes in as 20091231
chandra.shekhar@tcs.com
Premium Member
Premium Member
Posts: 353
Joined: Mon Jan 17, 2011 5:03 am
Location: Mumbai, India

Post by chandra.shekhar@tcs.com »

Use

Code: Select all

If DSLink77.ANLA_AIBDT = '00000000' Then setnull() Else StringToDate(DSLink77.ANLA_AIBDT,"%yyyy%mm%dd") 
Thanx and Regards,
ETL User
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I know, that's right there in your error message. You were meant to look at the question, answer "no" in your mind and then realize that you needed to fix the format you are using in the function call.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or you could just wait for someone to come along and hand you the answer on a silver platter. I believe in stimulating critical thinking and learning... teach a man to fish and all that rather than just handing him one.
-craig

"You can never have too many knives" -- Logan Nine Fingers
times29
Premium Member
Premium Member
Posts: 202
Joined: Mon Sep 22, 2008 3:47 pm

Post by times29 »

Thanks for fishing comments
i did try below and it worked but when i query database data is coming like 09-12-31
If DSLink77.ANLA_AIBDT = '00000000' Then setnull() Else StringToDate(DSLink77.ANLA_AIBDT,"%yyyy%mm%dd")
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I can't check but seem to recall having to use '0001-01-01' as low-date in DataStage in a project. Months 0 and Day 0 don't exist in any case, so '0000000' is not a legal date in any case.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That's all on your select query, assuming your target column is a DATE in the database. If you want it to come out in a particular format, you'd need to control the string conversion that is automatically going on. Oracle? Use "TO_CHAR" and the appropriate format mask. Others would be very similar.

And yes, not only is a zero date "not good for business" it's not a valid date so you couldn't load it if you wanted to. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
times29
Premium Member
Premium Member
Posts: 202
Joined: Mon Sep 22, 2008 3:47 pm

Post by times29 »

ok i am updating in database now so i put below sql in after sql it runs in datbase but i get below error

The OCI function executeDirect returned status -1. Error code: 1861, Error message: ORA-01861: literal does not match format string. (CC_OraUtils::handleBeforeAfterSQL, file CC_OraUtils.cpp, line 4633)

UPDATE AA.Test
SET ACQUIS_DATE = TO_CHAR(ACQUIS_DATE,'RRRRMMDD')
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

Seriously?

What Craig meant, was that if your target DB has the field set as DATE then when you look at the value and see 09-12-32, that is just the representation of the date in which ever tool you are using.

If you would like to see it represented otherwise, either change the settings in the view properties of whatever tool you are using to display the way you wish.

Else as Craig suggests, when using your select query to view the data you can choose how you wish to display your data by casting it whatever format you wish. The data in the DB doesn't need changing it is correct.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

ArndW wrote:I can't check but seem to recall having to use '0001-01-01' as low-date in DataStage in a project. Months 0 and Day 0 don't exist in any case, so '0000000' is not a legal date in any case.
Year 0000 doesn't exist either.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Yah, we skipped that one. :wink:
-craig

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