Working with Dates in Power Apps

Handling dates in Power Apps is a common requirement, whether you are formatting them for display or performing calculations such as adding days or finding differences.

This article walks through the essential techniques for working with dates, based on a practical example.

Setting Up the App

  • Add a Text Input control (e.g., TextInput1) where users can type a date and time.
  • Add a Label control to display the formatted date. Adjust font size, width, and alignment as needed.
  • Example input: December 15, 2025, 8:00 PM.

Formatting Dates

Dates can appear differently depending on regional settings. For example, some countries use day/month/year while others use month/day/year. To format dates consistently, use the Text function with a DateTimeValue conversion.


Text(
    DateTimeValue(TextInput1.Text),
    "dd/mm/yyyy"
)
  

This converts the string from the text input into a DateTime type and formats it as day/month/year.

Formatting Options

  • d → Day (single digit without leading zero)
  • dd → Day (two digits, adds leading zero if needed)
  • ddd → Abbreviated day of the week (e.g., Mon)
  • dddd → Full day of the week (e.g., Monday)
  • m → Month number
  • mmm → Abbreviated month (e.g., Dec)
  • mmmm → Full month name (e.g., December)
  • h → Hour (12-hour clock)
  • H → Hour (24-hour clock)
  • tt → AM/PM indicator

Example:


Text(
    DateTimeValue(TextInput1.Text),
    "dddd, mmmm dd, yyyy h:mm tt"
)
  

Output: Monday, December 15, 2025 8:00 PM

Localization

You can specify a locale to display dates in different languages or formats. By default, Power Apps uses the browser locale, but you can override it:


Text(
    DateTimeValue(TextInput1.Text),
    "dd mmmm yyyy",
    "pt-BR"
)
  

Output in Brazilian portuguese: 15 Dezembro 2025.

Using DateTimeFormat Enum

Instead of custom format strings, Power Apps provides predefined formats via DateTimeFormat enum:

  • DateTimeFormat.LongDateMonday, December 15, 2025
  • DateTimeFormat.LongDateTimeMonday, December 15, 2025 8:00:00 PM
  • DateTimeFormat.ShortDate12/15/2025

Date Calculations

While Text is useful for display, it returns a string and cannot be used for calculations.

For operations, use DateTime functions.

Adding Days


DateAdd(
    TextInput1.Text,
    30,
    TimeUnit.Days
)
  

Output: 1/14/2026 8:00 PM.

Adding Months


DateAdd(
    TextInput1.Text,
    2,
    TimeUnit.Months
)
  

Output: 2/15/2026 8:00 PM.

Finding Differences


DateDiff(
    "12/15/2025",
    "03/10/2026",
    TimeUnit.Days
)
  

Output: 85 days.

Key Takeaways

  • Use DateTimeValue to convert strings into date-time objects.
  • Use Text for formatting dates for display purposes.
  • Use DateAdd and DateDiff for calculations.
  • Leverage DateTimeFormat enum for quick predefined formats.
  • Always remember: Text returns a string, not a date-time type.

By mastering these functions, you can handle dates in Power Apps with flexibility—whether you need to display them in different formats, localize them for international users, or perform calculations for business logic.

Comments

Leave a Comment

Your email address will not be published. Required fields are marked *