The OutSystems UI Date Picker pattern uses Flatpickr under the hood. Set the DateFormat property to control display format (e.g., 'Y-m-d' or 'd/m/Y'), bind InitialDate to a Date variable, and handle the OnSelectedDateChanged event to capture the selected value. For formatting dates in expressions, use FormatDate(date, 'format_string') with OutSystems format tokens.
Date Picker Configuration and Date Formatting in OutSystems
OutSystems includes a standard Input widget with InputType = Date, but for real-world apps you need the OutSystems UI Date Picker pattern — it provides a calendar popup, min/max constraints, date range selection, and locale support via Flatpickr. This tutorial covers setup from scratch and includes the most common formatting expressions developers look up repeatedly.
Prerequisites
- A Reactive Web App with OutSystems UI library referenced (included by default in new apps)
- A screen open in the Screen Editor with a Form widget
- Familiarity with Local Variables in Service Studio
Step-by-step guide
Locate and add the Date Picker pattern
Locate and add the Date Picker pattern
In the Toolbox (left panel), search for 'Date Picker'. It appears under the Interaction category in the OutSystems UI section. Drag it inside your Form widget on the canvas. Service Studio places a DatePicker block on screen and may prompt you to accept the OutSystems UI library dependency — click Yes. The Date Picker is an OutSystems UI Block (not a native widget), so it appears in the Widget Tree as a block element with a label placeholder above it. Create a Local Variable: right-click screen → Add Local Variable → Name = 'SelectedDate', Type = Date, Default Value = CurrDate().
Expected result: A calendar icon input field appears on the screen. TrueChange shows no errors.
Configure the Date Picker input parameters
Configure the Date Picker input parameters
Select the Date Picker block on the canvas. In the Properties Panel (right side), find the block's Input Parameters: - DateFormat: enter 'dd/MM/yyyy' for day/month/year display (this uses OutSystems format tokens, not Flatpickr tokens — OutSystems translates internally). Common formats: 'MM/dd/yyyy' (US), 'yyyy-MM-dd' (ISO), 'dd MMM yyyy' (e.g., '30 Mar 2026') - InitialDate: bind to SelectedDate (your Local Variable) - MinDate: add expression for earliest selectable date, e.g. CurrDate() to prevent past dates - MaxDate: e.g. AddYears(CurrDate(), 1) to limit to one year ahead - ShowTodayButton: True to display a 'Today' shortcut in the calendar - DisabledWeekDays: integer list for disabled days (0=Sunday, 6=Saturday) — e.g. [0, 6] to disable weekends
1/* Date Picker input parameter expressions */2DateFormat: "dd/MM/yyyy"3InitialDate: SelectedDate4MinDate: CurrDate()5MaxDate: AddYears(CurrDate(), 1)6ShowTodayButton: True7DisabledWeekDays: [6, 0]Expected result: The calendar opens with today pre-selected, past dates greyed out, and weekends disabled.
Handle the OnSelectedDateChanged event
Handle the OnSelectedDateChanged event
The Date Picker fires OnSelectedDateChanged when the user picks a date. This event provides the selected date value so you can store it. Select the Date Picker block → Properties Panel → Events section → OnSelectedDateChanged → 'New Client Action'. Service Studio creates 'DatePickerOnSelectedDateChanged' and opens it. In the Action Flow Editor, the event provides a local parameter 'SelectedDate' (Date type) automatically. Assign it to your screen variable: Start → Assign: SelectedDate = SelectedDate (map event parameter to screen variable) → End Note: the parameter name in the event handler is also 'SelectedDate' by default — rename your screen variable to 'ChosenDate' to avoid confusion, or rename the event parameter.
1/* OnSelectedDateChanged Client Action */2/* Event input parameter: SelectedDate (Date) */3Start4 --> Assign: ChosenDate = SelectedDate5 --> EndExpected result: Picking any date in the calendar updates ChosenDate. Add an Expression widget to the screen bound to ChosenDate to verify the value updates live.
Format dates in expressions with FormatDate()
Format dates in expressions with FormatDate()
Use the FormatDate() built-in function whenever you need to display a date as a formatted string — in Expression widgets, labels, email bodies, or concatenated text. FormatDate syntax: FormatDate(Date/DateTime value, Text format_string) Format tokens: - yyyy or YYYY = 4-digit year (e.g. 2026) - yy = 2-digit year (e.g. 26) - MM = 2-digit month (01-12) - MMM = abbreviated month name (Jan, Feb, ...) - MMMM = full month name (January, February, ...) - dd = 2-digit day (01-31) - d = day without leading zero (1-31) - HH = 24-hour hours (00-23) - mm = minutes (00-59) - ss = seconds (00-59) Common examples: - FormatDate(CurrDate(), "dd/MM/yyyy") → '30/03/2026' - FormatDate(CurrDate(), "MMMM d, yyyy") → 'March 30, 2026' - FormatDate(CurrDateTime(), "yyyy-MM-dd HH:mm") → '2026-03-30 14:35'
1/* FormatDate expression examples */2FormatDate(CurrDate(), "dd/MM/yyyy") /* 30/03/2026 */3FormatDate(CurrDate(), "MMMM d, yyyy") /* March 30, 2026 */4FormatDate(CurrDateTime(), "yyyy-MM-dd HH:mm") /* 2026-03-30 14:35 */5FormatDate(OrderDate, "d MMM yyyy") /* 30 Mar 2026 */67/* Date arithmetic combined with FormatDate */8FormatDate(AddDays(CurrDate(), 30), "dd/MM/yyyy") /* 30 days from now */9FormatDate(AddMonths(CurrDate(), 3), "MMM yyyy") /* 3 months from now */Expected result: Expression widgets on screen display the ChosenDate in your chosen format. TrueChange confirms the expression type is Text (correct for Expression widget value).
Enable date range mode for start/end date selection
Enable date range mode for start/end date selection
The Date Picker supports a RangeDate mode that lets users select a start and end date with a single widget. To activate this, use the Date Picker's RangeDate parameter instead of InitialDate. Create two Local Variables: 'StartDate' (Date) and 'EndDate' (Date). In the Date Picker Properties Panel: - Remove the InitialDate binding - Set RangeDate: click the expression editor → create a DatePickerRangeDate structure: StartDate: StartDate EndDate: EndDate In the OnSelectedDateChanged event, the SelectedDate parameter becomes a DatePickerRangeDate structure. Update both variables: Start → Assign: StartDate = SelectedDate.StartDate, EndDate = SelectedDate.EndDate → End Display the range: FormatDate(StartDate, "dd/MM/yyyy") + " to " + FormatDate(EndDate, "dd/MM/yyyy")
1/* RangeDate binding */2RangeDate.StartDate = StartDate3RangeDate.EndDate = EndDate45/* OnSelectedDateChanged for range mode */6StartDate = SelectedDate.StartDate7EndDate = SelectedDate.EndDate89/* Display expression */10FormatDate(StartDate, "dd/MM/yyyy") + " to " + FormatDate(EndDate, "dd/MM/yyyy")Expected result: The calendar allows clicking a start date and then an end date, highlighting the range. Your StartDate and EndDate variables update correctly.
Complete working example
1/* Screen: DatePickerDemo23 Local Variables:4 ChosenDate : Date = CurrDate()5 StartDate : Date = NullDate()6 EndDate : Date = NullDate()78 Widget tree:9 Form10 Date Picker (single date mode)11 DateFormat: "dd/MM/yyyy"12 InitialDate: ChosenDate13 MinDate: CurrDate()14 MaxDate: AddYears(CurrDate(), 1)15 ShowTodayButton: True16 OnSelectedDateChanged: DatePickerOnSelectedDateChanged1718 Expression: FormatDate(ChosenDate, "MMMM d, yyyy")1920 Date Picker (range mode)21 RangeDate.StartDate: StartDate22 RangeDate.EndDate: EndDate23 OnSelectedDateChanged: RangeDatePickerOnSelectedDateChanged2425 Expression: FormatDate(StartDate,"dd/MM/yyyy") + " to " + FormatDate(EndDate,"dd/MM/yyyy")26*/2728/* Client Action: DatePickerOnSelectedDateChanged29 Input parameter: SelectedDate (Date) */30Start31 --> Assign: ChosenDate = SelectedDate32 --> End3334/* Client Action: RangeDatePickerOnSelectedDateChanged35 Input parameter: SelectedDate (DatePickerRangeDate) */36Start37 --> Assign: StartDate = SelectedDate.StartDate38 EndDate = SelectedDate.EndDate39 --> End4041/* Useful FormatDate reference:42 FormatDate(CurrDate(), "dd/MM/yyyy") = 30/03/202643 FormatDate(CurrDate(), "MMMM d, yyyy") = March 30, 202644 FormatDate(CurrDate(), "yyyy-MM-dd") = 2026-03-3045 FormatDate(CurrDate(), "d MMM yy") = 30 Mar 2646 FormatDate(AddDays(CurrDate(),7), "EEEE") = Sunday (day name)47*/Common mistakes
Why it's a problem: Storing a FormatDate() result (Text) in an entity attribute instead of the raw Date value
How to avoid: Always store dates as Date or DateTime type in entities. Format only at display time using FormatDate(). Storing '30/03/2026' as Text breaks date comparisons, sorting, and aggregation.
Why it's a problem: Binding InitialDate to a DateTime variable when the Date Picker expects a Date type
How to avoid: The Date Picker's InitialDate expects a Date type, not DateTime. Use DateTimeToDate(MyDateTimeVar) to convert if needed, or change the variable type to Date.
Why it's a problem: Using JavaScript-style date format strings (e.g. 'MM/DD/YYYY') in FormatDate()
How to avoid: OutSystems uses its own format tokens. 'MM' = month (01-12), 'dd' = day (01-31), 'yyyy' = 4-digit year. Using 'DD' gives the wrong result — 'DD' is not a valid token and will render literally.
Why it's a problem: Not handling OnSelectedDateChanged and wondering why the variable never updates
How to avoid: The Date Picker fires an event; it does not two-way bind directly to a variable. You must handle OnSelectedDateChanged and Assign the event's SelectedDate parameter to your screen variable.
Best practices
- Always handle OnSelectedDateChanged to store the picked date in a Local Variable — the Date Picker does not automatically two-way bind to a variable like a standard Input widget does.
- Use FormatDate() for display only. Store dates as the Date or DateTime data type in entities and variables — never as formatted Text strings.
- Set MinDate = CurrDate() for booking or scheduling forms to prevent users from selecting dates in the past.
- For date display in lists and tables, use FormatDate() in the Expression widget rather than relying on the default date toString rendering, which varies by locale.
- When comparing dates in filter expressions, compare Date variables directly (OrderDate >= StartDate) rather than comparing formatted strings.
- Test date formatting with the Test/Preview feature in Service Studio to confirm the format string produces the expected output before publishing.
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I'm using the OutSystems UI Date Picker pattern in a Reactive Web App. Explain how to: (1) configure DateFormat, MinDate, MaxDate, and ShowTodayButton properties, (2) handle the OnSelectedDateChanged event to store the date in a Local Variable, (3) use FormatDate() to display dates in various formats. Use OutSystems format tokens not JavaScript format strings.
Add an OutSystems UI Date Picker to my booking screen. Configure it with: DateFormat='dd/MM/yyyy', MinDate=CurrDate(), MaxDate=AddMonths(CurrDate(),6), ShowTodayButton=True. Create a ChosenDate Local Variable (Date type) and handle OnSelectedDateChanged to assign the picked date. Add an Expression widget showing FormatDate(ChosenDate, 'MMMM d, yyyy') below the picker.
Frequently asked questions
How do I display only the month and year (no day) in a Date Picker?
The standard Date Picker always shows a full calendar. For month-only selection, set the MonthSelector parameter to True (available in newer OutSystems UI versions) or use a custom Flatpickr configuration via a JavaScript node after the picker renders, setting the Flatpickr option: { plugins: [new monthSelectPlugin()] }.
Why does my date display in US format in the live preview but European format in production?
The Date Picker and FormatDate() use the format string you specify, not the system locale. If you see inconsistent formatting, check that your Expression widget is using FormatDate() explicitly rather than relying on the default date-to-string conversion, which is locale-dependent.
How do I get the day of the week name for a selected date?
OutSystems does not have a built-in DayOfWeekName() function. Use DayOfWeek(date) to get an integer (0=Sunday, 6=Saturday), then use an If expression or a Static Entity lookup to convert it to a name. Alternatively, FormatDate(date, 'EEEE') returns the full day name in some OutSystems versions — check your platform version.
Does the Date Picker work on mobile apps, or only Reactive Web?
The OutSystems UI Date Picker pattern is available in both Reactive Web and Mobile apps. On mobile, it renders a native-like calendar overlay optimized for touch. The same properties, events, and FormatDate() expressions work identically across both app types.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation