1822
Views
10
Comments
Format date in textbox input widget
I'm loading a date into a textbox that's attached to a Calendar widget.  The Calendar widget has its output date formatted so that it'll show up as MM-dd-YYYY, which is what I want.  

Is there any way to format the date in the textbox on the initial load so that it matches the format from the Calendar widget?
mvp_badge
MVP
Rank: #105
Hi Jared,

Check the DateFormat property of the Input_Calendar widget.

Follow the description:

Defaults to the date format defined in the server configuration. The defaults are "%Y-%m-%d" for Date and "%Y-%m-%d %H:%M:%S" for DateTime
Supported date formats:
    %a abbreviated weekday name
    %A full weekday name
    %b abbreviated month name
    %B full month name
    %C century number
    %d the day of the month ( 00 .. 31 )
    %e the day of the month ( 0 .. 31 )
    %H hour ( 00 .. 23 )
    %I hour ( 01 .. 12 )
    %j day of the year ( 000 .. 366 )
    %k hour ( 0 .. 23 )
    %l hour ( 1 .. 12 )
    %m month ( 01 .. 12 )
    %M minute ( 00 .. 59 )
    %n a newline character
    %p "PM" or "AM"
    %P "pm" or "am"
    %S second ( 00 .. 59 )
    %s number of seconds since Epoch (since Jan 01 1970 00:00:00 UTC)
    %t a tab character
    %U, %W, %V the week number5
    %u the day of the week ( 1 .. 7, 1 = MON )
    %w the day of the week ( 0 .. 6, 0 = SUN )
    %y year without the century ( 00 .. 99 )
    %Y year including the century ( ex. 1979 )
    %% a literal % character

You can also try to use masks, or format the source value of the input widget on preparation before the page is rendered.

Hope it helps.
Champion
Rank: #43

André Siébra wrote:

Hi Jared,

Check the DateFormat property of the Input_Calendar widget.

Follow the description:

Defaults to the date format defined in the server configuration. The defaults are "%Y-%m-%d" for Date and "%Y-%m-%d %H:%M:%S" for DateTime
Supported date formats:
    %a abbreviated weekday name
    %A full weekday name
    %b abbreviated month name
    %B full month name
    %C century number
    %d the day of the month ( 00 .. 31 )
    %e the day of the month ( 0 .. 31 )
    %H hour ( 00 .. 23 )
    %I hour ( 01 .. 12 )
    %j day of the year ( 000 .. 366 )
    %k hour ( 0 .. 23 )
    %l hour ( 1 .. 12 )
    %m month ( 01 .. 12 )
    %M minute ( 00 .. 59 )
    %n a newline character
    %p "PM" or "AM"
    %P "pm" or "am"
    %S second ( 00 .. 59 )
    %s number of seconds since Epoch (since Jan 01 1970 00:00:00 UTC)
    %t a tab character
    %U, %W, %V the week number5
    %u the day of the week ( 1 .. 7, 1 = MON )
    %w the day of the week ( 0 .. 6, 0 = SUN )
    %y year without the century ( 00 .. 99 )
    %Y year including the century ( ex. 1979 )
    %% a literal % character

You can also try to use masks, or format the source value of the input widget on preparation before the page is rendered.

Hope it helps.

Hi Jared,

Just try Andre you will find the solutions..


Regards,

Rajat Agrawal


Rank: #14026

Hi,


Is there a way to have the time only appear when the input widget appears? I tried using "%H:%M" in the DateFormat and ShowTime to True, but the dates still appear.


Regards,

Romuel

Champion
Rank: #43

Rom wrote:

Hi,


Is there a way to have the time only appear when the input widget appears? I tried using "%H:%M" in the DateFormat and ShowTime to True, but the dates still appear.


Regards,

Romuel


Hi Rom,

See below image only Time is displaying.. Try once more time


Regards,

Rajat Agrawal

Rank: #48250

Rajat Agrawal wrote:

Rom wrote:

Hi,


Is there a way to have the time only appear when the input widget appears? I tried using "%H:%M" in the DateFormat and ShowTime to True, but the dates still appear.


Regards,

Romuel


Hi Rom,

See below image only Time is displaying.. Try once more time


Regards,

Rajat Agrawal

I had the same problem. The date is still displaying when I try to select time...


Rank: #146

Hi Jared,


Please try it.

DateCapture.PNG

Rank: #1783

Hi Guys. I'm working on a OS11 Reactive APP and I have the same problem. I format the Date in the PickDate widget, but the Input Widget still presents the date as "YYY-MM-DD"


Rank: #1521

Hi David,

I've experienced the same issue you described.  I was able to overcome it on a Mobile app by doing the following:

1. Created a local variable on my screen with data type 'Text' - named it 'PickedStartDate';

2. Set the 'Variable' property of the input widget associated with the Date Picker to the local variable 'PickedStartDate' (created on the above step);

3. Set the data type of the input widget associated with the Date Picker as 'Text';

4. Set the DateFormat property of the DatePicker as "DD/MM/YYYY";

5. On my handler action DatePickerOnSelect, I assigned the variable 'PickedStartDate' to the 'StartDate' input parameter of that action.

6. On the save action for my screen, I added an assign to the top of the flow to cast the local variable 'PickedStartDate' from 'Text' to 'Date' data type and assigned it to the entity variable where I really wanted to save the date. An example would be GetVacationById.List.Current.Vacation.StartDate = TextToDate(PickedStartDate).

7. On my screen, I also created an OnAfterFetch action on my aggregate GetVacationById where I assigned the local variable PickedStartDate = DateToText(GetVacationById.List.Current.Vacation.StartDate) so that I can see the date that was previously saved on my input when I navigate to the screen.


And that's it! I'm pretty new to OutSystems but this solution is working for me so far.

I hope the above is useful to you, please let me know if you have any questions.


Kind regards,

Vanessa

Rank: #1783

Thank you Vanessa

Rank: #286

Hi Jared,

The simplest way is you can use the Input mask associated with your input, and then specify the required format in that like 'MM-dd-yyyy'.

Let me know , if this works for you. Thank you