383
Views
5
Comments
Solved
showing date and saving datetime
Question
Application Type
Reactive

Hi!

I wanted to show my date fields as only date: dd-MM-yyyy, but in the batabase (external) it is represented as datetime, so when I save the values it must be datetime. 

Is there any way to deal with this?

Thanks...

2024-07-05 14-16-55
Daniël Kuhlmann
Ā 
MVP
Solution

You now have the aggregate attribute directly in an expression. 

Something like 

Aggregate Name.List.Current.EntityName.AtrributeName

Change those to 

FormattedDate(Aggregate Name.List.Current.EntityName.AtrributeName)

2024-07-05 14-16-55
Daniël Kuhlmann
Ā 
MVP

Hi Diogo,

You can use the built-in function FormatDateTime to do that.

https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Logic/Built-in_Functions/Format#FormatDateTime

Best practise is to create your own public action that calls FormatDateTime, so that you have the format only defined on one place. Changing the format, if you want to in the future, is then limited to one action to be changed.

Regards,

Daniel

2023-11-10 11-46-42
Diogo Barbosa

Thanks,

I understand the idea, but how can that be done with that action?

I must make some assignment, I think... but I'm not seeing what to assign to apply it to all the dates...  I'm missing something :)

2024-07-05 14-16-55
Daniël Kuhlmann
Ā 
MVP
  1. Create a client action FormattedDate
  2. Input parameter called InputDateTime of datatype DateTime
  3. Output parameter of datatype Text called FormattedDate
  4. Use the the Assign widget
  5. In the assign widget assign FormatDateTime(InputDateTime, "dd-MM-yyyy") to FormattedDate
  6. Set the property IsFunction to True.
  7. Now on every place where you still have the DateTime attribute directlty displayed from an aggregate, put it inside FormattedDate()
2023-11-10 11-46-42
Diogo Barbosa

That looks great! :))

I just didn't understand the point 7... how to apply the function to the fields? 

2024-07-05 14-16-55
Daniël Kuhlmann
Ā 
MVP
Solution

You now have the aggregate attribute directly in an expression. 

Something like 

Aggregate Name.List.Current.EntityName.AtrributeName

Change those to 

FormattedDate(Aggregate Name.List.Current.EntityName.AtrributeName)

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