How to change format date in input
Application Type
Traditional Web

Can u help me?

i have question,

How to change format date to "dd-MM-yyyy" in input when input get CurrDate() from default value in entity.

or or if you have a best practice way you can tell me.


Thank you

TicketExercise.oml

mvp_badge
MVP
Solution

Hi Muhammad,

  • As already mentioned, the default date format is "YYYY-MM-DD"
  • However, based on the observation I had while debugging the code, the input linked with the DatePicker control is forcefully assigning a formatted date value with a custom date format, i.e. "DD-MM-YYYY". 
  • Therefore, the captured date value conversion fails under the hood, i.e. from custom formatted date value to the default Date format value and the placeholder of the associated Form attribute (TicketForm.Record.Ticket.CreatedOn) still holds a null date value.
  •  Hence, the value is set as an invalid/Null date value on the record save.
  • For better clarification I would suggest you degugg the code and watch the TicketForm.Record.Ticket.CreatedOn attribute value on setting the input date value using the DatePicker control.


I made some changes to your implementation. Please refer to the attached OML

Solution:

  • Define a local variable of Text Data type called CreatedOn
  • Map the CreatedOn local variable to the CreatedOn date input widget Variable property
  • Set the Null value of the input to CurrDate()

  • Define an OnSelect Event handler on the DatePicker and assign the StartDate input parameter value to the TicketForm.Record.Ticket.CreatedOn

I hope this helps you!


Kind regards,

Benjith Sam

Exercise.oml

This is for the Database 

TicketExerciseCore.oml

Hi Muhammad,

If you use DatePicker instead of RichWidgets\Input_Calendar the problem will be solved.


Regards,

Yusuf

DatePicker.png

Hi 

You can manage it from service center.

Hi,

If you just want to change the format showed on page for only some pages, you can use the widget Controls/DatePicker and set the format to format the date.

If you also want to change the format for all applications and all page, you can change the configuration in Service Center, 

Hi,

In addition to the above inputs you can use FormatDate in-build function to get your date formatted based on your requirement.



Thanks,

Sandeep.

Dear @Yusuf Kerim Tüysüz , @Vijay Malviya , @Merliny 

Thank you for the answers you gave.

I have done the suggestions you guys gave and it worked on the ticket details page, but I have a problem on the report page and in my database.

why on the report page and in the database it doesn't want to save CurrDate() data even though I have given the CurrDate() value in the CreatedOn entity or in the InitialDate Controls\DatePicker properties. Why does my database always store the NullValue of the CreatedOn input form which is "#1900-01-01#" ? can you help me solve this problem?



Thank you.









Hi,

i think u can't store null values into an Outsystems  Entity DateTime . you can make it text if you want

Can you tell what are you trying to achieve?


Hi,

I have tried the same logics and settings, and it works fine. Can you upload the oml file, and let me check it. 

Dear @Merliny 

This is my oml file

Exercise.oml

ExerciseCore.oml

mvp_badge
MVP
Solution

Hi Muhammad,

  • As already mentioned, the default date format is "YYYY-MM-DD"
  • However, based on the observation I had while debugging the code, the input linked with the DatePicker control is forcefully assigning a formatted date value with a custom date format, i.e. "DD-MM-YYYY". 
  • Therefore, the captured date value conversion fails under the hood, i.e. from custom formatted date value to the default Date format value and the placeholder of the associated Form attribute (TicketForm.Record.Ticket.CreatedOn) still holds a null date value.
  •  Hence, the value is set as an invalid/Null date value on the record save.
  • For better clarification I would suggest you degugg the code and watch the TicketForm.Record.Ticket.CreatedOn attribute value on setting the input date value using the DatePicker control.


I made some changes to your implementation. Please refer to the attached OML

Solution:

  • Define a local variable of Text Data type called CreatedOn
  • Map the CreatedOn local variable to the CreatedOn date input widget Variable property
  • Set the Null value of the input to CurrDate()

  • Define an OnSelect Event handler on the DatePicker and assign the StartDate input parameter value to the TicketForm.Record.Ticket.CreatedOn

I hope this helps you!


Kind regards,

Benjith Sam

Exercise.oml

Hi Muhammad,

I think this is a bug of the widget 'Controls/DatePicker'. We can use 'RichWidgets/Input_Calendar' instead. The configurations are the same, please refer to below:

I have tried this, it works fine.

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