Page 1 of 1

date conversion from 05aug08 to yymmdd

Posted: Fri Aug 29, 2008 9:17 am
by kkumardatastage
hi
pls can any one help me to converting the date formet from

1) 05aug08 to yymmdd and
2) 05aug08 to yyyymmdd.

i am using datastage parallel
this conversion i am doing in transformer.
pls can any get me a solution
thank you

Posted: Fri Aug 29, 2008 9:26 am
by DSguru2B
Try looking into StringToDate using the mask '%dd%mmm%yy'. This will convert your string to date. The output format will depend upon what you have set at the project level for dates.

Re: date conversion from 05aug08 to yymmdd

Posted: Fri Aug 29, 2008 10:01 am
by kkumardatastage
kkumardatastage wrote:hi
pls can any one help me to converting the date formet from

1) 05aug08 to yymmdd and
2) 05aug08 to yyyymmdd.

i am using datastage parallel
this conversion i am doing in transformer.
pls can any get me a solution
thank you

Try looking into StringToDate using the mask '%dd%mmm%yy'. This will convert your string to date. The output format will depend upon what you have set at the project level for dates.


pls can u tell me in detail i did't got u properly.
thank you

Posted: Fri Aug 29, 2008 10:02 am
by kkumardatastage
DSguru2B wrote:Try looking into StringToDate using the mask '%dd%mmm%yy'. This will convert your string to date. The output format will depend upon what you have set at the project level for dates.
pls can u tell me in detail i did't get u properly
thank you

Posted: Fri Aug 29, 2008 10:09 am
by DSguru2B
Read about StringToDate() in your manuals to get an understanding of how these functions work.
Your incoming format is %dd%mmm%yy, so you will feed this to StringToDate.

Code: Select all

StringToDate(in.col, '%dd%mmm%yy')
this will convert your String into Date.
Now as for your output format, that depends upon your project level settings for Date.

Posted: Fri Aug 29, 2008 11:19 am
by kkumardatastage
DSguru2B wrote:Read about StringToDate() in your manuals to get an understanding of how these functions work.
Your incoming format is %dd%mmm%yy, so you will feed this to StringToDate.

Code: Select all

StringToDate(in.col, '%dd%mmm%yy')
this will convert your String into Date.
Now as for your output format, that depends upon your project level settings for Date.
hi
thank you for u r help, i am getting output but in view data the date in appering as all *********. but i need to get in the form of (yyyymmdd) for ex:my input is in form 05AUG08 and my output in the view data should be in format of (20080805). pls can u give me some solution for this
thank you one's again

Posted: Fri Aug 29, 2008 12:22 pm
by DSguru2B
Is your output date or a string format? Lets start with that before we jump any forward.

Posted: Fri Aug 29, 2008 2:25 pm
by kkumardatastage
DSguru2B wrote:Is your output date or a string format? Lets start with that before we jump any forward.
hi
the target column for the date is in the verchar
thank you

Posted: Mon Sep 01, 2008 1:35 am
by poornima.chandramouli
kkumardatastage wrote:
DSguru2B wrote:Is your output date or a string format? Lets start with that before we jump any forward.
hi
the target column for the date is in the verchar
thank you
Hi,

Are you using this conversion as a part of your stage variables.
If you are doing so, then check the order of execution of your stage variables.

Posted: Mon Sep 01, 2008 2:16 am
by sandeepgs
Hi,

Question : To convert format of date.

1) 05aug08 to yymmdd and
2) 05aug08 to yyyymmdd

Solution: Use this function in transformer It will work.

This is for fist one:

DateToString(StringToDate(DSLink8.a,"%dd%mmm%yy"),"%yy%mm%dd")

Second one:

DateToString(StringToDate(DSLink8.a,"%dd%mmm%yy"),"%yyyy%mm%dd")

Note : DSLink8.a is a column name specifiy the incomming column name here.

Posted: Tue Sep 02, 2008 7:47 am
by kkumardatastage
sandeepgs wrote:Hi,

Question : To convert format of date.

1) 05aug08 to yymmdd and
2) 05aug08 to yyyymmdd

Solution: Use this function in transformer It will work.

This is for fist one:

DateToString(StringToDate(DSLink8.a,"%dd%mmm%yy"),"%yy%mm%dd")

Second one:

DateToString(StringToDate(DSLink8.a,"%dd%mmm%yy"),"%yyyy%mm%dd")

Note : DSLink8.a is a column name specifiy the incomming column name here.
hi
thank you for u r help, i used DateToString(StringToDate(DSLink8.a,"%dd%mmm%yy"),"%yy%mm%dd") i am getting output but in view data the date in appering as all *********. but i need to get in the form of (yyyymmdd) for ex:my input is in form 05AUG08 in verchar and my output in the view data should be in format of (20080805)(verchar). pls can u give me some solution for this

thank you
:cry:

Posted: Tue Sep 02, 2008 1:07 pm
by singhald
first correct your expression to get correct required ouput format in yyyymmdd,


Incorrect= DateToString(StringToDate(DSLink8.a,"%dd%mmm%yy"),"% yy%mm%dd ")
Correct =DateToString(StringToDate(DSLink8.a,"%dd%mmm%yy"),"%yyyy%mm%dd")

now check the datatype for this field in the ouput stage. it should be varchar 8,

also open the file and see the data format, dont worry about the datastage view option,

Regards