Demonstrate text and format a date or time – PowerApps, Microsoft Docs

In this article

Add dates and times, and format them to showcase the right level of detail or to reflect your locale. Calculate the amount of time inbetween two dates, or calculate a date that’s a certain amount of time before or after a date that you specify. Convert dates to or from separate values for days, months, and years, and convert times to or from separate values for hours, minutes, and seconds.

For example, add data from users about stock trades or client meetings, data from an outward source, or data from another app created in PowerApps. If that data includes times down to the millisecond, round it to the nearest minute for plainness. Calculate how many days remain before a major milestone. If you want to schedule client meetings every five days, calculate those dates automatically. If May Ten, 1985, is stored in separate fields for the day, the month, and the year, consolidate them into a single value. Conversely, break each date into separate values if your app manages them separately.

Prerequisites

  • Sign up for PowerApps, install it, open it, and then sign in by providing the same credentials that you used to sign up.
  • Create an app or open an existing app in PowerApps.
  • Learn how to configure a control in PowerApps.

Display text in a Label control

Demonstrate text in a Label control by setting the value of its Text property. Set this property by typing directly into the control or by typing an expression in the formula bar.

  • If you type directly into the control, it shows exactly what you type.
  • If you type an expression in the formula bar, the control shows the result of the expression.

Here are some examples.

If your computer is set to the ",en-us", locale, the current date and time emerges in this format:

If your computer is set to a locale such as ",fr-fr",, the current date and time shows up in this format:

The control shows the number of days inbetween today and January 1, 2020, by using these functions:

  • DateDiff, which calculates the number of days, quarters, or years inbetween two dates.
  • Today, which calculates the current day as a value.
  • DateValue, which converts a literal string, as shown inbetween dual quotation marks, to a value on which calculations can be performed.

In BirthDate, type the month and the day of your birth (for example, 05/Legitimate).

ShowText shows the number of days inbetween today and whatever date you type into BirthDate. If your bday has already occurred this year, ShowText displays a negative value.

Format dates and times by using DateTimeValue

Convert dates and times from strings of text to values, which you can format in a multitude of ways and use in calculations. Specify the format by using built-in and custom-built options.

The DateTimeValue and DateValue functions can convert dates in any of these formats into values:

  1. Add a Text input control named ArrivalDateTime, and type a date and time in this format:

ShowDate shows the same information that you typed, but it’s been converted from text to a value and formatted differently. For example, the year shows up as four digits instead of just two.

Switch the Text property of ShowDate to this formula:

ShowDate shows the day before the month, as a French user would expect.

To display a list of other locales in Intellisense, eliminate the closing quotation mark and fr from the formula, but leave the open quotation mark:

To use one of several built-in formats, switch the Text property of ShowDate to this formula:

ShowDate shows the day of the week, the date, and the time.

The DateTimeFormat parameter supports several other built-in formats. To display that list, eliminate LongDateTime from the formula.

To use a custom-built format, switch the Text property of ShowDate to this formula:

Text(DateTimeValue(ArrivalDateTime.Text), ",mm/dd/yyyy hh:mm:ss.fff AM/PM",)

ShowDate shows the date/time value in the format that you specified, including milliseconds.

To round the time to the nearest tenth or hundredth of a 2nd, specify hh:mm:ss.f or hh:mm:ss.ff in the formula.

Format a date by using DateValue

Add a Text input control named ArrivalDate, and then type a date in it (for example, Five/Ten/85).

Add a Label control named FormatDate, and set its Text property to this formula:

FormatDate shows the date that you typed, except the year shows up as four digits.

Set the Text property of FormatDate to this formula:

FormatDate shows the day before the month, just as a French user would expect.

To use one of several built-in formats, set the Text property of FormatDate to this formula:

FormatDate shows the day of the week, the month, the day, and the year.

To use a custom-built format, set the Text property of FormatDate to this formula:

FormatDate shows the date in the format that you specified.

Format a time using DateTimeValue

To use one of several built-in formats, set the Text property of ShowTime to this formula:

ShowTime shows the time that you specified, including seconds.

To use a custom-built format, set the Text property of ShowTime to this formula:

Text(DateTimeValue(ArrivalTime.Text), ",hh:mm:ss.fff AM/PM",)

ShowTime shows the time that you specified, including seconds and milliseconds.

To round the time to the nearest tenth or hundredth of a 2nd, come in hh:mm:ss.f or hh:mm:ss.ff in the formula.

Demonstrate the time inbetween dates

DateDiff shows 275, which is the number of days inbetween April 1, 2015, and January 1, 2016.

DateDiff(DateValue(Embark.Text), DateValue(End.Text), Months)

DateDiff shows 9, which is the number of months inbetween April 1, 2015, and January 1, 2016. Substitute Months with Quarters or Years to showcase the time in those units.

Identify a date before or after another date

DateAdd shows Five/13/1985, which is three days after the date in Commence.

DateAdd shows Five/7/1985, which is three days before the date in Begin.

Switch the Text property of DateAdd to this formula:

DateAdd(DateValue(Embark.Text), Trio, Months)

The label shows 8/Ten/1985, which is three months after the date in Embark. Substitute Months with Quarters or Years to identify a date that’s the specified number of quarters or years before or after the date in Embark.

Calculate dates based on years, months, and days

Add a Label control, and set its Text property to this formula:

Text(Date(Value(Year.Selected.Value), Value(Month.Selected.Value), Value(Day.Selected.Value)), DateTimeFormat.LongDate)

Wednesday, January 1, 2014 is listed by default. Select different values in the Drop down controls to switch the date in the Label control.

You may need to convert data that you didn’t expect. If you add Text input controls instead of Drop down controls, a user may come in an incorrect date, such as May 45. The Date function treats atypical data in the following ways:

  • If a year value is inbetween 0 and 1899 (inclusive), the function adds that value to 1900 to calculate the year.
  • If a year value is inbetween 1900 and 9999 (inclusive), the function uses that value as the year.
  • If a year value is less than 0 or is 10000 or greater, the function comes back an error value.
  • If a month value is greater than 12, the function adds that number of months to the very first month of the specified year.
  • If a month value is less than 1, the function subtracts that many months, plus 1, from the very first month of the specified year.
  • If a day value is greater than the number of days in the specified month, the function adds that many days to the very first day of the month and comebacks the corresponding date from a subsequent month.
  • If a day value is less than 1, the function subtracts that many days, plus 1, from the very first day of the specified month.

Calculate times based on hours, minutes, and seconds

Add a Label control, and set its Text property to this formula:

You can add entries to Hour and Minute so that users can select from a fatter range of hours and a more precise number of minutes. You can also add a third Drop down control so that users can specify seconds. If you add a third list, set the Text property of the Label control to the following expression:

Related movie: HOW TO GET A Gf IN GTA Five (Gta Five Online)


Leave a Reply

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