Attribute DataType change

Hello Everyone,

I have an issue with my records in the entity , Getting in detail i have an attribute which was set to number type and data was bootstrapped , so i have an update now that the same attribute have to accept time values into the records on changing the datatype for that attribute the existing data with in the records(of type number eg. 2 ) were  getting affected and getting changed to 00:00 .

I even tried using text type and bootstrapped the data into the entity as here which was filling my requirement 50% but getting date displayed to the record with the time as shown in the below fig.

In the above figure  the time displayed isn't required , So how can i fix this ?


Hope i can get some answers to fix this issue.

Champion

Hi Jaswanth

Can you be a little more specific about what you want to accomplish?

If I understand you correctly,  you have an attribute in an entity, that needs to save both integer and DateTime type data. It's actually not possible. then you change to Text type.

But I'm not sure what do you want to display in the List?

Kind regards,


Hi,

You can change the data type to only date instead of Date Time , and update the data using screen, it will work properly.

Regards,

-K.K.-

Hello.

I am not sure if this is what you want to accomplish but if you want to display only the Date part of the text (when it's a date time) while showing the numbers if it isn't a date, you can try to put this in your expression of the column:

if(TextToDateTimeValidate(<text_var>), TextToDate(<text_var>), <text_var>)

If this is not what you want, please give us more details.

Regards,

mvp_badge
MVP

Hello Jaswanth,

When you create an Entity and define an attribute, its data type must be "fixed".
This is a Database requirement more than an OutSystems requirement.

So, you can't have an attribute that is at the same time a "Date" and an "Integer". 

If you really need to store this information in the same column, the workaround is the one you used, that is, to store it as text.

But this leads to another problem, that is: How you show the information on the screen?

You need to properly identify the type of information stored for each row you want to show and use the correct format. In this regard, Tiago Oliveira provided a good solution (using an IF function in an expression) to identify if the information is a Date or not and show it accordingly. 

But this approach: storing multiple different data type values in the same attribute, is a terrible idea...

It will make your code harder to implement, read and maintain.

I don't know why you have this requirement, but it is a bad one.

Cheers.


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.