How to Change column data type in collection

Hi I have a collection (read data from web page) , I wanted to to change one column data type to date time? How to do that? Intially that column is in text data type.
From text to date time. How? Please give any suggestions?
 

Leonard Scmidt

New Member
You can use a code stage. Add new column with datetime data type to your collection, assign text value to new column, delete old column.
 

sivagelli

Well-Known Member
There is no direct way to type cast columns in Collections. You can try adding a column of type date time and convert the data from String to DateTime using Loop Stage and Calc stages.

To add a Column of DateTime type, you have to -
  • Duplicate 'Append Filed (text)' action from Collection Manipulation VBO and replace 'System.String' with 'System.DateTime'
Now, use Loop Stage and convert your string to DateTime using ToDateTime() expression.

Post back how it goes!
 

maria.cojocea

New Member
There is actually a straightforward way to cast Column Types, it works for Number to Text and Text to DateTime (and most probably vicerversa, too).

You need 2 stages as per the attached, in order to copy the values from the 1st Collection ([Initial Column Types]) into a brand new Collection, 2nd Collection ([Converted Column Types]) for which you setup the Columns to be of the type you want.
 

Attachments

  • Stage 1.PNG
    11.2 KB · Views: 759
  • Stage 2.PNG
    104.8 KB · Views: 752
  • Stages.PNG
    13.3 KB · Views: 682
  • DateTime (DateTime).PNG
    7.4 KB · Views: 647

Amarender

Member
There is actually a straightforward way to cast Column Types, it works for Number to Text and Text to DateTime (and most probably vicerversa, too).

You need 2 stages as per the attached, in order to copy the values from the 1st Collection ([Initial Column Types]) into a brand new Collection, 2nd Collection ([Converted Column Types]) for which you setup the Columns to be of the type you want.

Hi Maria.Cojocea

Unable to follow your flow. can you please send the full flow Diagram.
 

akinak

New Member
There is actually a straightforward way to cast Column Types, it works for Number to Text and Text to DateTime (and most probably vicerversa, too).

You need 2 stages as per the attached, in order to copy the values from the 1st Collection ([Initial Column Types]) into a brand new Collection, 2nd Collection ([Converted Column Types]) for which you setup the Columns to be of the type you want.

Hi Maria, This is for a defined collection. Is there any way, when collection is dynamic?
Thanks.
 

iamshiva

New Member
There is actually a straightforward way to cast Column Types, it works for Number to Text and Text to DateTime (and most probably vicerversa, too).

You need 2 stages as per the attached, in order to copy the values from the 1st Collection ([Initial Column Types]) into a brand new Collection, 2nd Collection ([Converted Column Types]) for which you setup the Columns to be of the type you want.
Its works like a charm.
 
Top