Date Conversion
Moderators: chulett, rschirm, roy
Date Conversion
My source data is a flat file in which i am getting date column as 'CYYMMDD' where C = 1 or 0 which represents 2000 and 1900 centuries, YY - year, MM - month and DD - date.
For example: source column is in the format '1050713', target should be in this format ' July 13, 2005'. Any advice of how to do this in PX. I would really appreciate that.
For example: source column is in the format '1050713', target should be in this format ' July 13, 2005'. Any advice of how to do this in PX. I would really appreciate that.
Since leading zeroes need to be retained, you should be reading this column as char and conditionally derive the date value by either adding 1900 or 2000 to the YYMMDD portion and then casting into the appropriate target column.
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Re: Date Conversion
thanks, it worked
Re: Date Conversion
Hi Samu could u give the function u used to get the date format n how did u eliminate the 1 from the date given in flat filesamu wrote:thanks, it worked
thanks in advance.
RK
Re: Date Conversion
Hi ravij,ravij wrote:Hi Samu could u give the function u used to get the date format n how did u eliminate the 1 from the date given in flat filesamu wrote:thanks, it worked
thanks in advance.
RK
I didn't use any function to get my date format., simply i implemented exactly what kcdland suggested ie., simply add 19 for 0 and 20 for 1 and take it as char. U can eliminate 1 or 0 by using a little bit of logic and then concatinate (add 19 and 20) the string to get ur YYYYMMDD date format and then convert string to date. Hope this will clear somethings for u.
samu
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
But someone else on the early part of the learning curve might like to benefit from your experience. Can you advise what stage type you used and what expression(s) you used to solve this?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ray.wurlod wrote:But someone else on the early part of the learning curve might like to benefit from your experience. Can you advise what stage type you used and what expression(s) you used to solve this?
Hi Ray,
Let me explain it clearly. Iam getting date format from flat file which is in the form of CYYMMDD ., in which C-century, YY-year, MM-month and DD-date.
For example: in source if i have '1050414' , i need to get it in form 'April 14,2005'
So they are 2 ways to go about this, if you have data type of the DATE in the source as 'date' and not 'varchar or char' then you have to convert it into 'string' by using transformer stage, by defining a stage variable or in the derivation cell., simply convert ur date column into string by going into 'Functions' and then in 'function' go to 'type conversion' and in 'type conversion' goto 'datetostring(%inputcolumn%)' where in you can give which column needs to be converted to string.
(P.S: you don't need this if ur data type is defined as 'varchar or char')
After that define another stage variable in the transformer just below the first stage variable
(P.S : don't create it above the first stage variable, it wouldn't work since Datastage follows a order in solving stage variables).
In that use 'if then else logic' where in you use 'if (input column[1,1] = '1' then '20':inputcolumn[2,6] else '19':inputcolumn[2,6]'
After that once again create another stage variable below stage variable 2 , where in you would be converting this string to date in the same way as u did for first stage variable but here u have to use 'stringtodate(%inputcolumn%)' and then put this stage variable in your target column in transformer stage whose datatype must be defined as date. Then while loading in to respective databases it will show up in the format i.e., 'July 14, 2005'.
Got that senoras and senoritas
Thanks
samu
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 2
- Joined: Fri Dec 16, 2005 11:51 am
Subtracting two Dates and the result should be in date forma
Hello,
I have two dates and format is TimeStamp and the database is Oracle. if I subtract the date from one date to another date, I used the following in transformation.
OConv(DateTimeStampToInternal(DSLink3.milestone_date) - DateTimeStampToInternal(DSLink3.milestone_capture_date), 'yyyy-mm-dd hh24:mi:ss')
But the result is not in the date format.
Please help me
Thanks,
Senthil.
I have two dates and format is TimeStamp and the database is Oracle. if I subtract the date from one date to another date, I used the following in transformation.
OConv(DateTimeStampToInternal(DSLink3.milestone_date) - DateTimeStampToInternal(DSLink3.milestone_capture_date), 'yyyy-mm-dd hh24:mi:ss')
But the result is not in the date format.
Please help me
Thanks,
Senthil.
SENTHIL MURUGAN V
Welcome aboard. Since you're posting a new message for your own separate issue, please start a new message thread. That will force you to enter all of the relevant information, such as your version of DataStage, etc.
You're asking a Server question in the Parallel forum, so please repost there.
Thanks.
You're asking a Server question in the Parallel forum, so please repost there.
Thanks.
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle