Canvas Apps Expressions

D – Dates – learn how to format!

A calendar
A calendar

Introduction

Makers use dates pretty extensively in Power Apps. Different countries format dates in different ways. For example, October 1st 2023 will be written as 10/1/2023 whereas in India the same date will be written as 1/10/2023.

Formatting dates - Option 1

Makers use Text function for several purposes. One of them being formatting dates. A lot of makers use the Text function with placeholders to denote the desired format. For example, the following codes generates "Sunday, February 5, 2023" as the output.

Text(
    Now(),
    "ddddd, mmmm d, yyyy"
)

Formatting dates - Option 2

While the above method works, writing formats using placeholders is just not the most efficient way. There are tons of enumerations available in Power Apps. Use these to make formatting dates a breeze. Here is an example using enumerations to generate the same output as above:

Text(
    Now(),
    DateTimeFormat.LongDate
)

To check out all the enumerations and to learn more about the Text function, click here. There are several date functions available as well. To learn more about them, click here.

Stay tuned for the remaining 22 tips!

Recent articles

  1. C - Custom pages - how to add multiple screens?
  2. B - Batch updates using ForAll or not - Which is better?
  3. A - Accordion gallery - How to make one in Power Apps

Leave a Reply